MapView setCenter () not working as expected

I have an Activity where MapView is on a part of the screen. Here I always focus my location on a given point. Then I have another activity where the MapView is full screen and I'm focusing on the location of the users. When I have returned from the entire MapView screen to an activity with a MapView on a part of the screen, I call setCenter () on the MapView again. But now the MapView is not in the right place, but a few meters away somewhere else. When I use animateTo () everything works as expected. Is this some kind of setCenter () error or how do I explain this strange behavior to myself?

+3


source to share


2 answers


Well, a working solution is to use this:



controller.setCenter(getPoint);
controller.animateTo(getPoint);

      

+4


source


I think there may be many possibilities that setCenter () does not work. I've spent quite some time on my own setCenter problem. AnimateTo () does not solve my problem. In fact, from the MapController documentation, setCenter specifically "sets the map display to this center, there will be no animation", so setCentre () is like moving to that point without animation.

In the end, the one that solves my problem seems to be: I need to call setCentre () AFTER calling setZoom () to set the zoom level.



Additional info: I am using OSMDroid mapView with offline maps.

+1


source







All Articles