C# 如何在xamarin中获取当前gps坐标
我想在xamarin中获取用户当前ios的纬度和经度 据我所知,我看过其他帖子 就像: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(); 然而,当我在模拟
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开始,有点迷路了。