2
votes

I'm using Mapsui 2.0-beta.22 and Xamarin Forms 3.4.0 for my app. I can't get map centering work, I have tried many examples from stack, other sites and Mapsui examples.

The only "available" method for me is:

map.Home = n => n.NavigateTo(sphericalMercatorCoordinate, map.Resolutions[9]);

from examples, as Mapsui version I'm using does not have methods in Map class to center view.

I was trying to center map from MapViewModel method:

public async override void OnNavigatedTo(INavigationParameters parameters)

and I was passing Point coords in NavigationParameters, then used them to create sphericalMercatorCoordinate. Even if the point is valid, using NavigateTo from above is not working in any case.

1

1 Answers

2
votes

The map.Home method is meant to specify the initial viewport. If you want to zoom to any viewport or location after initialization you need to use:

mapControl.Navigator.NavigateTo