Android Question Google Maps - Orientation Change Redraw

RichardN

Well-Known Member
Licensed User
Longtime User
A layout loaded in Activity_Create contains a MapFragment. The Process Global 'Gmap as GoogleMap' contains the map which has some markers and labels added in the main body of the code.

In attempting to redraw the map on device reorientation (in Activity_Resume) I get a map, but only ever get a full world view centred on Latitude/Longitude 0/0 without markers or labels.

What is the correct technique for storing the view using Process Globals and redrawing a map in the Activity_Resume event?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
The simplest solution is to limit your app to a specific orientation.

If it is not possible then you should maintain the map state yourself and then recreate it. Maintaining the state means that you add the markers information to a process global List (custom types can help here) whenever you add a marker. Then when Activity_Create is called you go over the list and add the markers.
 
Upvote 0

RichardN

Well-Known Member
Licensed User
Longtime User
Thanks Erel.

Just for the experience I recreated a map view on reorientation as you suggested, preserving the key elements as Process Globals as well as the overall WindowState (remember those?). The logic within the Activity_Resume event is not quite as simple as one might imagine but it can be made to work.

My conclusion is that it is not worth the effort. The user experience is degraded as even over high speed wifi there is a significant wait for the map to redraw, this is particularly true in the case of my app where I was exclusively using Satellite view.

iOS is so much better in this regard.
 
Upvote 0
Top