Android google maps

Hey, I have a very weird problem with displaying google maps on android. If I add them like that

addContentView(mapView, params);

View is added fine and I can see Google logo on the bottom, however maps are invisible. If I minimalize and then maximalize my app maps are displayed just fine. @singmajesty do you know why this might happen? Is openfl blocking something?

1 Like

Here’s my code.

RelativeLayout rl = new RelativeLayout(Extension.mainActivity);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.MATCH_PARENT,
RelativeLayout.LayoutParams.MATCH_PARENT);					
Extension.mainActivity.addContentView(rl, params);
					
					
MapView map = new MapView(Extension.mainActivity);
map.onCreate(savedInstanceState);
map.onResume();

rl.addView(map);

A little update, not all devices have this problem, some load maps just fine.

You doing it wrong. You should call onCreate in onCreate and onResume in onResume (also onSaveInstanceState and other methods).

Depending on what you want it may be easier to use MapFragment / SupportMapFragment onstead of using MapView directly.

Unfrotunately moving methods doesn’t change anything, if I use relative layout map won’t display on some devices untill I press home button. I’m not really sure if this is realted to openfl, I found some posts on stackoverflow about very similar issue with google maps v2.