I am trying to send the lattitude,longitude from my web service to the bing Maps,this is my code for the map:
<Grid>
<Grid.Resources>
<CollectionViewSource x:Name="LocationList"/>
<DataTemplate x:Key="LogoTemplate">
<bm:Pushpin>
<bm:MapLayer.Position>
<bm:Location Latitude="{Binding local_latit}" Longitude="{Binding local_longi}"></bm:Location>
</bm:MapLayer.Position>
</bm:Pushpin>
</DataTemplate>
</Grid.Resources>
<bm:Map Credentials="...">
<bm:Map.Children>
<bm:MapItemsControl x:Name="ListOfItems"
ItemsSource="{Binding Source={StaticResource LocationList}}"
ItemTemplate="{StaticResource LogoTemplate}">
</bm:MapItemsControl>
</bm:Map.Children>
</bm:Map>
</Grid>
this is my code behind:
private async void Page_Loaded(object sender, RoutedEventArgs e)
{
UriString3 = "URL";
var http = new HttpClient();
http.MaxResponseContentBufferSize = Int32.MaxValue;
var response = await http.GetStringAsync(UriString3);
var rootObject = JsonConvert.DeserializeObject<MyApp.Models.RootObject>(response);
var se = new Location();
se.Latitude = rootObject.local_latit;
se.Longitude = rootObject.local_longi;
LocationList.Source = se; //exception at this line
}
this is my model Class:
public class RootObject
{
.....
public double local_longi { get; set; }
public double local_latit { get; set; }
}
I get this exception:
"Value does not fall within the expected range."
so any help please,to send the lattitude,langitude to the map thanks for help
Update: this is the value of lattituden,longitude when debugging:
