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?

Answers


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:

mMapView.getController().animateTo(location);
                        mMapView.getController().setZoom(GlobalValues.EMERGENCY_MAP_ZOOM_LVL);

Need Your Help

How to get progress in Http post Android?

android http http-post

Is there a way to get progress data, to display ProgressBar(Horizontal), using DefaultHttpClient with image encoded to Base64 in params. I am also sending some other params. Similar thing is achiev...

Python Script vs Cron Job

python cron archlinux

I need to run a cron job to generate a list of user rankings each week at exactly "00:00:00" UTC each Monday morning. Has anyone got an example for this, it's really doing my head in ... I looked i...