【问题标题】:CivicAddressResolver always returning UnKnownCivicAddressResolver 总是返回 UnKnown
【发布时间】:2018-11-08 06:00:06
【问题描述】:

我正在尝试使用 System.Device.Location 命名空间根据 GeoCoordinate 获取国家/地区名称。 以下是我尝试过的代码

 GeoCoordinateWatcher watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.Default);
        watcher.MovementThreshold = 1.0; // set to one meter

        CivicAddressResolver resolver = new CivicAddressResolver();

        for (int k = 0; k < 100; k++)

        {

            watcher.TryStart(false, TimeSpan.FromMilliseconds(2000));
            GeoCoordinate coord = watcher.Position.Location;

            Console.WriteLine("Temp " + k + ", status: " + watcher.Status.ToString());

            if (coord.IsUnknown != true)
            {
                CivicAddress address = resolver.ResolveAddress(watcher.Position.Location);


                Console.WriteLine("Lat: {0}, Long: {1}",
                    coord.Latitude,
                    coord.Longitude);
                Console.WriteLine("Country ",address.CountryRegion);

            }
            else
            {
                Console.WriteLine("Unknown latitude and longitude.");
            }
        }

使用此代码,我能够成功获取经纬度,但地址总是未知。即使我尝试了一些纬度和经度。我正在使用 .NET Framework 4.7.2。

请帮我解决这个问题。提前致谢

【问题讨论】:

  • github 中有一个小项目——也许这会有所帮助? github.com/nuitsjp/GeoCoordinator
  • 感谢@JohnB 的回复,该项目用于获取坐标。在我的项目中,我得到了它

标签: c# .net geolocation location


【解决方案1】:

我有同样的问题。得出的结论是即使在 .net 4.8 上也没有实现 CivicAddressResolver。 使用观察者的坐标,我可以使用 Google Maps API 为坐标返回紧密匹配的地址

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多