开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜