有什么方法可以在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!");
}
}
感谢您的帮助!
如果是这样,您可以使用PushPin
来显示上的当前位置map
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句