【问题标题】:windows phone 8 - How to display longitude and latitude coordinates on map (current location)windows phone 8 - 如何在地图上显示经度和纬度坐标(当前位置)
【发布时间】:2014-12-15 01:55:10
【问题描述】:

有没有办法在 c# windows phone 8 应用程序的简单地图上显示我从当前位置获得的坐标?

这是我用来获取当前位置的代码。目前它只在文本块中显示坐标,但我需要将其转换为在地图上显示位置。

private async void GetCurrentLocation()
    {
        Geolocator locationFinder = new Geolocator();
        try
        {
            Geoposition currentLocation = await locationFinder.GetGeopositionAsync(
            maximumAge: TimeSpan.FromSeconds(120),
            timeout: TimeSpan.FromSeconds(10));
            String longitude = currentLocation.Coordinate.Longitude.ToString("0.00");
            String latitude = currentLocation.Coordinate.Latitude.ToString("0.00");
            MyTextBlock.Text = "Long: " + longitude + "Lat: " + latitude;
        }
        catch (UnauthorizedAccessException)
        {
            MessageBox.Show("And exception occured!");
        }
    }

感谢您的帮助!谢谢!

【问题讨论】:

  • 换句话说,你想在地图上测试它吗?
  • @Kulasangar 完全正确。我的目标是在地图上显示该位置
  • 我在下面发布了一个建议!

标签: c# windows-phone-8 geolocation maps latitude-longitude


【解决方案1】:

如果是这样,您可以使用PushPinmap 上显示当前位置。

参考:Windows Phone : Location : Map : Pushpin

【讨论】:

  • 谢谢...这就是工作。但不知何故......这不是我想的那样我的位置......它只是西雅图附近的某个随机位置......就像在你的例子中一样。我需要显示我的当前位置:(
  • 您是否尝试通过您的Emulator 进行操作? stackoverflow.com/questions/21659312
  • 这似乎可以解决问题,但只是暂时的。每当我退出应用程序并重新启动它时,它会再次显示“redmond”位置,我必须再次设置新位置。不是最好的解决方案 imo,因为它不会自行找到您的位置,它只会显示您之前标记的位置。
  • 可能是您没有初始化将位置设置在正确位置的函数。尝试将调用放在 NavigatedTo 或 Initialize 过程中......适合我这样的人!
猜你喜欢
  • 2011-10-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-01-04
相关资源
最近更新 更多