Android 百度地图(三):知识点小结

使用百度地图知识点小结

1、设置地图比例(MapStatusUpdateFactory.zoomTo();)

    //设置比例,标尺大约500米
 MapStatusUpdate msu=MapStatusUpdateFactory.zoomTo(15.0f);
         mBaiduMap.setMapStatus(msu);

2、地图切换

//设置普通地图、卫星地图、实时交通地图
mBaiduMap.setMapType(BaiduMap.MAP_TYPE_NORMAL);
mBaiduMap.setMapType(BaiduMap.MAP_TYPE_SATELLITE);
mBaiduMap.setTrafficEnabled(true);

3、进行定位(locationclient 、LocationListener)

locationclient = new LocationClient(getApplicationContext());
        // 注册要写在setContentView上面
        locationclient.registerLocationListener(myListener);

4、添加覆盖物(addOverlay)

mBaiduMap.addOverlay(new MarkerOptions().position(result.getLocation())
                .icon(BitmapDescriptorFactory
                        .fromResource(R.drawable.ic_launcher)));

5、画线

List<LatLng> points = new ArrayList<LatLng>();
//之后需要对points设置两、三个点
OverlayOptions ooPolyline = new PolylineOptions().width(10)
                .color(0xAAFF0000).points(points);
        mBaiduMap.addOverlay(ooPolyline);

6、自定义图标需要一个BitmapDescription

//初始化图标
iconlocation=BitmapDescriptorFactory.fromResource(R.drawable.main_icon_nav);
    //设置自定义图标
            MyLocationConfiguration congig=new MyLocationConfiguration(MyLocationConfiguration.LocationMode.NORMAL, true, iconlocation);
            mBaiduMap.setMyLocationConfigeration(congig);

7、模式切换

//普通模式、罗盘模式、跟随模式
LocationMode    locationmode=LocationMode.NORMAL;
LocationMode    locationmode=LocationMode.COMPASS;
LocationMode    locationmode=LocationMode.FOLLOWING;
//添加模式
    MyLocationConfiguration congig=new MyLocationConfiguration(locationmode, true, iconlocation);
            mBaiduMap.setMyLocationConfigeration(congig);

你可能感兴趣的:(Android 百度地图(三):知识点小结)