Android - Two Maps in one App

2020-07-24 05:42发布

I got an App where on main screen show google mapView. But I need also in details view show the map.

I know that it is impossible to run two maps simultaneously. Everything is working when I want to show something on the main map and later in detailed view, but when I come back to main one, it stops.

How to stop main map and come back later to it?

3条回答
地球回转人心会变
2楼-- · 2020-07-24 06:11

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.

查看更多
我只想做你的唯一
3楼-- · 2020-07-24 06:23

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();
查看更多
混吃等死
4楼-- · 2020-07-24 06:30

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.

查看更多
登录 后发表回答