如何在一个Activity上创建2个MapView?
是否有可能在一个Activity上创建2个MapView?
如果是这样,怎么做?
我试过但没有运气。
提前致谢。
简短的回答是否定的 。
目前,Android仅支持每个MapActivity一个MapView。
是的可能的 ,我用这个代码的两种不同的地图------ 1.获取GPS位置------ 2.获取一些位置时,它的地区/城市/国家名称进行搜索。 代码是,
    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();
 }
注意:确保您在调用此方法和之前设置了ContentView
int arg
在这里用来指示哪个mapView将被调用.....我使用过
链接地址: http://www.djcxy.com/p/43957.html