2016-01-21 97 views
0

我有在把一個標記,以便在我的兵地圖的每個位置的問題,這是我的代碼: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" 

而這就是我得到的調試時: enter image description here

我得到了「位置」變量,爲什麼我在地圖只得到一個標記的所有結果

這是教程,我遵循: 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> 

回答

1

嘿嘗試綁定一個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>