windows phone 8 - 如何在地图上显示经度和纬度坐标(当前位置)

时间:2014-12-15 01:55:11

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

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

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

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!");
        }
    }

感谢任何帮助!谢谢!

1 个答案:

答案 0 :(得分:0)

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

参考:Windows Phone : Location : Map : Pushpin