Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/285.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在xamarin中获取当前gps坐标_C#_Ios_Xamarin_Cllocationmanager - Fatal编程技术网

C# 如何在xamarin中获取当前gps坐标

C# 如何在xamarin中获取当前gps坐标,c#,ios,xamarin,cllocationmanager,C#,Ios,Xamarin,Cllocationmanager,我想在xamarin中获取用户当前ios的纬度和经度 据我所知,我看过其他帖子 就像: CLLocationManager lm = new CLLocationManager(); ... (Acurray) ... (Other Specs) lm.StartUpdatingLocation(); lm.Location.Coordinate.Latitude.ToString(); lm.Location.Coordinate.Longitude.ToString(); 然而,当我在模拟

我想在xamarin中获取用户当前ios的纬度和经度

据我所知,我看过其他帖子

就像:

CLLocationManager lm = new CLLocationManager();
... (Acurray)
... (Other Specs)
lm.StartUpdatingLocation();
lm.Location.Coordinate.Latitude.ToString();
lm.Location.Coordinate.Longitude.ToString();
然而,当我在模拟器中运行它时,它什么也不做。它并没有要求我打开我的定位服务或用纬度和经度更新我的标签


此外,我如何让it部门检查it定位服务是否已打开,如果未打开,则如何让it部门检查。如何让用户这样做。(就像某些应用程序上的弹出窗口要求您打开gps)

CLLocationManager是异步的-当位置更新时,它将触发事件

CLLocationManager lm = new CLLocationManager(); //changed the class name
... (Acurray)
... (Other Specs)

lm.LocationsUpdated += delegate(object sender, CLLocationsUpdatedEventArgs e) {
    foreach(CLLocation l in e.Locations) {
        Console.WriteLine(l.Coordinate.Latitude.ToString() + ", " +l.Coordinate.Longitude.ToString());
    }
};

lm.StartUpdatingLocation();

CLLocationManger是异步的-它将在位置更新时触发事件

CLLocationManager lm = new CLLocationManager(); //changed the class name
... (Acurray)
... (Other Specs)

lm.LocationsUpdated += delegate(object sender, CLLocationsUpdatedEventArgs e) {
    foreach(CLLocation l in e.Locations) {
        Console.WriteLine(l.Coordinate.Latitude.ToString() + ", " +l.Coordinate.Longitude.ToString());
    }
};

lm.StartUpdatingLocation();

你知道如何从纬度和经度获取位置名称吗?使用反向地理编码-@Jason这仍然有效吗?CLLocationManager的命名空间是什么??那些是什么??试图获取坐标,但刚从Xamarin开始就有点迷路了。你知道如何从纬度和经度获取位置名称吗?使用反向地理编码-@Jason这仍然有效吗?CLLocationManager的命名空间是什么??那些是什么??试图获取坐标,但只是从Xamarin开始,有点迷路了。