Android - Two Maps in one App

旧巷老猫 提交于 2019-12-04 17:44:22

Having two maps in one app produces many weird application behavior. For example, Ive had overlays from one map show up in the second map.
That said, it is possible to have two maps in one application without the above happening. What you need to do is to specify a new process for the second mapview:

<activity
        android:label="@string/app_name"
        android:name=".SecondMapActivityName"
        android:process=":SecondMapProcess"
         >
</activity>

The above code lies in the manifest and is for the activity containing the second MapView. This way a new process starts for this activity within the same app and both your maps behave as they should.

What I do is create a new mapview in code each time I want to use it (yes overhead but it works ;)).

mMapView = new MapView(this, MAPS_KEY);
setContentView(mMapView);
mMapView.invalidate();

If you don't need to interact with your other map, you can use it in lite mode: https://developers.google.com/maps/documentation/android-api/lite

It creates a bitmap image that looks like a map.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!