Map resets when button is clicked

I have an app which has a map, a button, and a text field. When the screen opens, the map is initialized to centre on the current location and has an initial zoom level of 1. The text field says “0”. The act of clicking the button, has an action of increasing a counter and updates the text field to show the new value of the counter.

Suppose I open the app and use my fingers to zoom the map closer and to move the map so that it is no longer centred on my location. For some reason, when I then click the button, the map resets back to being centred on my location and having a zoom of 1. There is no map-related code attached to the button. All of the map-related code is in an “onMapReady” event block. Does anyone know how I can avoid the map resetting when the button is clicked?

Hi,

This is really a problem. The Map component does not retain its current state. By this, the presence and activation of even an empty event processing block of any component results in updating the Map and resetting it to its original state. I did not find a way to avoid this.

I’m having this same problem. As soon as any button on the Screen is pressed, the map snaps back into whichever position it was in at ‘onMapReady’.

The original post here was a year ago, but I haven’t been able to find any remedy to this. Am I missing something?

How do I solve it? I change the coordinates of latitude and longitude in the processing unit of the event of clicking on the map or marker.