<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:map="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginBottom="5dp" android:layout_weight="1" android:orientation="horizontal" > <fragment android:id="@+id/map1" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginRight="5dp" android:layout_weight="1" class="com.baidu.mapapi.map.SupportMapFragment" /> <fragment android:id="@+id/map2" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" class="com.baidu.mapapi.map.SupportMapFragment" /> </LinearLayout> </LinearLayout>
public class MultiMapViewDemo extends FragmentActivity { private static final LatLng GEO_BEIJING = new LatLng(39.945, 116.404); private static final LatLng GEO_SHANGHAI = new LatLng(31.227, 121.481); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_multimap); initMap(); } /** * 初始化Map */ private void initMap() { MapStatusUpdate u1 = MapStatusUpdateFactory.newLatLng(GEO_BEIJING); SupportMapFragment map1 = (SupportMapFragment) (getSupportFragmentManager() .findFragmentById(R.id.map1)); map1.getBaiduMap().setMapStatus(u1); MapView mapView = map1.getMapView(); mapView.showScaleControl(false); mapView.showZoomControls(false); mapView.setLogoPosition(LogoPosition.logoPostionRightTop); MapStatusUpdate u2 = MapStatusUpdateFactory.newLatLng(GEO_SHANGHAI); SupportMapFragment map2 = (SupportMapFragment) (getSupportFragmentManager() .findFragmentById(R.id.map2)); map2.getBaiduMap().setMapStatus(u2); map2.getMapView().setLogoPosition(LogoPosition.logoPostionRightTop); } }
1、MapView
2、BaiduMap
3、BaiduMapOptions:MapView 初始化选项
4、MapStatusUpdateFactory和MapStatusUpdate、MapStatus.Builder和MapStatus