How to to make 2 MapView on one Activity?

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.


The short answer is no .

Currently Android supports only one MapView per MapActivity.


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

链接地址: http://www.djcxy.com/p/43958.html

上一篇: 获取与桌面关联的登录Windows用户名

下一篇: 如何在一个Activity上创建2个MapView?