【发布时间】:2013-07-29 15:50:51
【问题描述】:
我只是第一次通过定位服务工作,一切似乎都在正常工作,它可以正确找到我的位置,但我无法提取坐标。
文档指出 CLLocation 具有“坐标”属性,编译器对这段代码很满意。但是在运行时 CLLocation 似乎只返回一个字符串描述。
我启动位置管理器
_locationManager = new CLLocationManager ();
_locationManager.DesiredAccuracy = 1000;
// handle the updated location method and update the UI
_locationManager.LocationsUpdated += (object sender, CLLocationsUpdatedEventArgs e) => {
UpdateLocation (e.Locations [e.Locations.Length - 1], _destinationLatitude, _destinationLongitude);
};
if (CLLocationManager.LocationServicesEnabled)
_locationManager.StartUpdatingLocation ();
事件正确触发
static public void UpdateLocation (CLLocation current, Double destinationLat, Double destinationLng)
{
//Make the start pairing
string start = current.Coordinate.Latitude.ToString() + "," + current.Coordinate.Longitude.ToString();
//Make the destination pairing
string destination = destinationLat.ToString() + "," + destinationLng.ToString();
}
但是应用程序只是崩溃了。在断点上捕获它我看到以下内容,它似乎只有一个包含的描述属性。
Description "<+50.58198902,-3.67661728> +/- 65.00m (speed -1.00 mps / course -1.00) @ 25/07/2013 13:11:28 British…" string
我显然可以从这个文本字段中提取 lat/lng,但我觉得我不应该这样做。任何帮助表示赞赏。
【问题讨论】:
-
您可以运行 LocationManager 示例应用程序吗?
-
谢谢。核心位置示例工作正常。它会给我一些比较的东西。
标签: xamarin.ios xamarin cllocation