您好我正在尝试创建一个应用程序来帮助人们学习新区域并找到商店等,这意味着为每个项目显示不同的地图。我在json文件中包含了long和lat:
[
{
"UniqueId": "Group-1-Item-1",
"Title": "Bear Grill",
"Subtitle": "Grill",
"ImagePath": "Assets/theBearGrill.png",
"Description" : "Item Description:",
"Content" : "Curabitur class aliquam vestibulum nam curae maecenas sed,
"Latitude": 28.4195,
"Longitude": -81.5812
},
但是我无法弄清楚如何从地图控件中访问它,我已经在项目的类中设置了get和set方法,但是不知道如何将值加载到Geo坐标中。
<Maps:MapControl Name="map" HorizontalAlignment="Left" Margin="19,212.833,0,0" Grid.Row="1" VerticalAlignment="Top" Height="221" Width="357" ManipulationMode="All" MapServiceToken="AlM1jaSStpZ8pXuB1WYsLCxv1b-KmsrF4IeoZFpsFO9YPQn4xBsA7Os7CkTmNQ02" ZoomLevel="18"/>
private void Button_Click(object sender, RoutedEventArgs e)
{
map.Center = new Windows.Devices.Geolocation.Geopoint(new Windows.Devices.Geolocation.BasicGeoposition {Longitude = 0 , Latitude = 0 });
map.ZoomLevel = 18;
map.Style = Windows.UI.Xaml.Controls.Maps.MapStyle.Aerial;
map.LandmarksVisible = true;
}
任何帮助都会被推荐,因为我之前从未做过windows app dev
下面是更新的方法,它将引脚放下但不指向正确的坐标
private async void addMap(double latitude, double longitude, string title)
{
MapIcon MapIcon1 = new MapIcon();
MapIcon1.Location = new Geopoint(new BasicGeoposition() { Longitude = longitude, Latitude = latitude });
MapIcon1.NormalizedAnchorPoint = new Point(1.0, 1.0);
MapIcon1.Title = title;
LocalMap.MapElements.Add(MapIcon1);
Geolocator gl = new Geolocator()
{
DesiredAccuracy = PositionAccuracy.High
};
try
{
Geoposition gp = await gl.GetGeopositionAsync();
TripDistance.Text = "Long = " + gp.Coordinate.Point.Position.Longitude + " " + "Lat" + gp.Coordinate.Point.Position.Latitude;
//centerMap(gp.Coordinate.Point.Position.Latitude, gp.Coordinate.Point.Position.Longitude);
}
catch (Exception ex)
{
TripDistance.Text = "Error!!";
}
LocalMap.Center = new Geopoint (new BasicGeoposition { Latitude = latitude, Longitude = longitude });
LocalMap.ZoomLevel = 15;
LocalMap.Style = MapStyle.AerialWithRoads;
slider.Value = LocalMap.ZoomLevel;
}