Multiple map views?

2020-07-31 06:19发布

问题:

I have an application that has two map views one satellite and one street view. They both keep showing up as a satellite view even though one is set to setStreetView(true); and the other is set to setSattelite(true);. How would I get it so that both views show different maps?

Thanks in advance.

回答1:

Assuming you are talking about showing both at the same time, it doesn't appear to be possible. See How to Make 2 MapView on One Activity

Updated to respond to comment.

Per the Google Map API MapActivity, "Only one MapActivity is supported per process. Multiple MapActivities running simultaneously are likely to interfere in unexpected and undesired ways." So even if you have two different MapActivities you have to deal with the Process Lifecycle, where perhaps one activity is visible and the other activity is background and that is where you are getting problems.

2nd Update

So according to this thread Limitations of the MapView and MapActivity one commenter put a separate activity between two MapActivities and was able to make it work, but otherwise you will have to use overlays/find a way to make your app work with only one MapActivity.



回答2:

A solution is proposed here.

It's known that you might experience some issues when using multiple mapviews in one process. Usually this is the case (your app running in one process) if you don't configure anything specific. You could though use the android:process attribute in your manifest to assign to your activites