I develop simple Xamarin.Forms application with GoogleMaps using MVVMCross. My goal is to center maps' position to user's current location while launching it. Unfortunately I don't know how to bind these values to GoogleMaps' constructor. Right now it's just static value but I want to pass values of latitude and longitude from CurrentLocation object (which has these properties).
View:
<ContentPage.Content>
<maps:Map MapType="Street" IsShowingUser="True" HasZoomEnabled="True">
<x:Arguments>
<maps:MapSpan>
<x:Arguments>
<maps:Position>
<x:Arguments>
<x:Double>56.368533</x:Double>
<x:Double>3.258646</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>
</ContentPage.Content>
Here's part of my ViewModel:
public class NearbyBollardsMapViewModel : MvxViewModel
{
private Location _currentLocation;
public Location CurrentLocation
{
get => _currentLocation;
set
{
_currentLocation = value;
RaisePropertyChanged(() => CurrentLocation);
}
}
public NearbyBollardsMapViewModel(ILocationService locationService)
{
this._locationService = locationService;
CurrentLocation = _locationService.GetCurrentUsersLocation().Result;
}
}