Multimarkers在Bing地图
问题描述:
我有在把一个标记,以便在我的兵地图的每个位置的问题,这是我的代码:Multimarkers在Bing地图
private async void geolocator_PositionChanged(Geolocator sender, PositionChangedEventArgs args)
{
await
// Need to get back onto UI thread before updating location information
this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, new DispatchedHandler(
async() =>
{
UriString4 = "my URL";
var http = new HttpClient();
http.MaxResponseContentBufferSize = Int32.MaxValue;
var response = await http.GetStringAsync(UriString4);
var rootObject = JsonConvert.DeserializeObject<NvBarberry.Models.RootObject>(response);
Location[] location = new Location[int.Parse(rootObject.total)];
for (int i = 0; i < int.Parse(rootObject.total); i++)
{
//Get the current location
location[i] = new Location(rootObject.locals[i].local_latit,rootObject.locals[i].local_longi);
//Update the position of the GPS pushpin
MapLayer.SetPosition(GpsIcon, location[i]);
//Set the radius of the Accuracy Circle
GpsIcon.SetRadius(args.Position.Coordinate.Accuracy);
//Make GPS pushpin visible
GpsIcon.Visibility = Windows.UI.Xaml.Visibility.Visible;
//Update the map view to the current GPS location
MyMap.SetView(location[i], 17);
}
}));}
这是我想要得到local_longi JSON数据和 local_latit每个地点:
{
success : 1,
total : 2,
locals : [{
id_local : "59",
local_longi : "20",
local_latit : "25894"
}, {
id_local : "60",
local_longi : "10.33699",
local_latit : "25.997745"
}
]
}
的问题是,我得到的地图,这是从经度,Lattitude最后一个位置上只有一个标记(根据塔JSON数据我得在地图上只有位置。这个值:
local_longi: "10.33699",
local_latit: "25.997745"
我得到了“位置”变量,为什么我在地图只得到一个标记的所有结果
这是教程,我遵循: https://blogs.bing.com/maps/2012/11/05/getting-started-with-bing-maps-windows-store-apps-native/
更新: 这是对我的地图XAML代码:
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<m:Map Name="MyMap" Credentials="1m8dxWklva2lte3kYjkn~........" ZoomLevel="13" />
<CheckBox Content="GPS" Click="GPS_Checked"/>
</Grid>
答
嘿尝试绑定一个OberservableCollection图钉(从我的班级)。
<Maps:MapItemsControl ItemsSource="{x:Bind ViewModel.Pushpins}">
<Maps:MapItemsControl.ItemTemplate>
<DataTemplate x:DataType="model:Pushpin">
<StackPanel Maps:MapControl.Location="{x:Bind Location, Converter={StaticResource PointConverter}}"
Maps:MapControl.NormalizedAnchorPoint="{x:Bind Path='', Converter={StaticResource DefaultAnchorPointConverter}}">
<TextBlock Text="{x:Bind Title}"
Foreground="Black" />
<Image Source="{x:Bind Path='', Converter={StaticResource PushpinConverter}}" />
</StackPanel>
</DataTemplate>
</Maps:MapItemsControl.ItemTemplate>
</Maps:MapItemsControl>