8

Is it possible to make 2 MapView on one Activity ?

If so, How to make it ?

I've tried but no luck.

Thanks in advance.

AndroiDBeginner
  • 3,571
  • 11
  • 40
  • 43

2 Answers2

4

The short answer is no.

Currently Android supports only one MapView per MapActivity.

Reto Meier
  • 96,655
  • 18
  • 100
  • 72
  • @Reto Meier How about Using Two SupportMapFragment in One FragmentActivity?I use it but it create this kind of Problem.http://stackoverflow.com/questions/22946152/using-two-supportmapfragment-in-one-activity-but-unable-remove-marker-from-secon – Herry Apr 18 '14 at 12:44
0

yes possible, I used this code for two different kinds of maps------ 1. for getting gps location------2. for getting some location when it is searched by its area/city/country name. The code is,

    public void mapDisplay(double lat, double lng, int arg){

        if(arg == 1){
            mapView = (MapView)findViewById(R.id.map_view);
        }
        else if (arg ==2 ){
            mapView = (MapView)findViewById(R.id.map_view2);

        }

        mapView.setBuiltInZoomControls(true);

        //mapView.setStreetView(true);
        //mapView.setTraffic(true);
        //mapView.setSatellite(true);

        // to display the pin point
        List<Overlay> mapOverlays = mapView.getOverlays();
        Drawable drawable = this.getResources().getDrawable(R.drawable.icon);
        CustomItemizedOverlay itemizedOverlay = new CustomItemizedOverlay(drawable, this);

        GeoPoint point = new GeoPoint((int) (lat * 1E6), (int)(lng * 1E6));

        OverlayItem overlayitem = new OverlayItem(point, "", "");
        itemizedOverlay.addOverlay(overlayitem);
        mapOverlays.add(itemizedOverlay);

        mapView.getController().setZoom(18);
        mapView.getController().setCenter(point);
        mapView.getController().animateTo(point);

        mapView.invalidate();

 }

Note: Make sure that you have set the ContentViews before calling this method and

int arg

is used here to indicate that which mapView is going to be called.....I used

Husnain Iqbal
  • 83
  • 1
  • 3
  • 5