【问题标题】:CLLocation does not have a Coordinates propertyCLLocation 没有坐标属性
【发布时间】: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


【解决方案1】:

我将完全相同的代码移到不同的控制器中,它运行良好。两个控制器之间的唯一区别是失败的控制器使用单点触控对话框反射 API 来绑定屏幕元素。我不明白为什么这会有所不同,但这是两个控制器之间的唯一区别。现在一切正常,如果有时间,我会尝试在较小的样本中重现。

【讨论】:

    猜你喜欢
    • 2014-12-04
    • 1970-01-01
    • 2021-06-25
    • 1970-01-01
    • 2014-08-26
    • 1970-01-01
    • 2019-01-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多