【发布时间】:2014-02-18 23:53:46
【问题描述】:
我已经从工具箱向应用程序添加了一个地图,但我试图弄清楚如何向地图添加一个标记,该标记将由按钮的单击事件触发。我知道如何获取设备的当前位置,如下所示。
但是我将如何添加到此以使用此位置数据在地图上绘制图钉/标记?有没有一种简单的方法可以使用从这段代码 sn-p 计算的 lat/lng 添加标记?
Geolocator geolocator = new Geolocator();
geolocator.DesiredAccuracyInMeters = 50;
try
{
Geoposition geoposition = await geolocator.GetGeopositionAsync(
maximumAge: TimeSpan.FromMinutes(5),
timeout: TimeSpan.FromSeconds(10)
);
LatitudeTextBlock.Text = geoposition.Coordinate.Latitude.ToString("0.00");
LongitudeTextBlock.Text = geoposition.Coordinate.Longitude.ToString("0.00");
}
catch (Exception ex)
{
if ((uint)ex.HResult == 0x80004004)
{
// the application does not have the right capability or the location master switch is off
StatusTextBlock.Text = "location is disabled in phone settings.";
}
//else
{
// something else happened acquring the location
}
}
【问题讨论】:
标签: c# windows-phone-8 geolocation maps