Search code examples
androidxamarin.formsmapsrenderer

Xamarin Forms Maps MoveToLastRegionOnLayoutChange not working as expected


I have an issue with the Forms Maps. When I drag the map and move away to a different screen, I see the map back to the last location set using "MoveToRegion" when I resume back the map screen. As per the documentation, setting MoveToLastRegionOnLayoutChange to False should prevent this behavior but it doesn't.

I didn't specifically test this property for screen rotation, but Renderer doesn't change on app sleep and resume.

Tried with below:

  • Xamarin Forms V16.6.000.1062
  • Android V8.1
  • Visual Studio 2019 V16.6.3

UPDATE: I realized that it is not merely a case of Page resume, but the page is rendered as below:

mapInstance = MapsPage.SelfInstance ?? new MapsPage();
Detail = new NavigationPage(mapInstance);

Here, I store the page instance in SelfInstance the first time it is instantiated, so the page is not initialized again. Result below:

Map Issue Gif

Here is the link to code sample I created with above result.


Solution

  • Reported this on XF Github page:

    https://github.com/xamarin/Xamarin.Forms/issues/11488