I am using Xamarin.forms.Maps
for showing the map in my project. The map is inside the ListView
and I need to bind the coordinate positions to the map.
Model Class:
public class History
{
public double Latitude { get; set; }
public double Longitude { get; set; }
}
Data adding part:
historyList.Add(new History() { Latitude= -28.854930 ,Longitude= 151.166023 });
historyList.Add(new History() { Latitude = -28.853671, Longitude = 151.165712 });
historyList.Add(new History() { Latitude = -28.853934, Longitude = 151.167118 });
historyList.Add(new History() { Latitude = -28.855178, Longitude = 151.167946 });
historylistview.ItemsSource = historyList;
XAML
<ListView x:Name="historylistview">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
<StackLayout
HorizontalOptions="Center">
<maps:Map
x:Name="maps"
VerticalOptions="Center"
HorizontalOptions="Center">
<x:Arguments>
<maps:MapSpan>
<x:Arguments>
<maps:Position>
<x:Arguments>
<x:Double>{Binding Latitude}</x:Double>
<x:Double>{Binding Longitude}</x:Double>
</x:Arguments>
</maps:Position>
<x:Double>0.01</x:Double>
<x:Double>0.01</x:Double>
</x:Arguments>
</maps:MapSpan>
</x:Arguments>
</maps:Map>
</StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
The map is showing in each row but the position value are wrong. I have given location from Texas but the map is showing somewhere in Nijerya.
Is binding is possible to do for the type x:Arguments
?