Using more than one mapview in single application
My application contains tab layout(TabHost, TabSpec). I am using two map views in my application. So if I am enabling satellite view in one map_activity then go to the other map_activity then other map is also shown in satellite view, if I drag one map_activity towards USA other map view is also automatically dragged towards USA no matter where it was earlier pointing. I general if we run two activity in different processes using android:process=":map1" and android:process=":map2" then we can solve the above problem. I referred here... But how can we solve this problem in tab bar(TabHost, TabSpec) applications?
This is not a perfect solution, but it'll get the job done, sort off.
In those tabs where you need the mapview you create it in code:
mMapView = new MapView(this, MAPS_KEY); mMapView.setClickable(true); LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); mMapView.setLayoutParams(params); FrameLayout mapFrame = (FrameLayout) findViewById(R.id.map_container); mapFrame.addView(mMapView);
The xml is self explanatory (if not just request).
The problem with this approach is that when the mapview is instantiated it will remember the old position, so you need to move the map to the new position you want it to be at. Could be done like this: