android:高德地图标记

定义

private AMap aMap;
MapView mMapView = null;
private UiSettings mUiSettings;//定义一个UiSettings对象

写在protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState)…}

 //获取地图控件引用
mMapView = (MapView) findViewById(R.id.map);
//在activity执行onCreate时执行mMapView.onCreate(savedInstanceState),创建地图
mMapView.onCreate(savedInstanceState);

主要的方法

  private void gaodemap(float longitude,float latitude){
        if (aMap == null) {
            aMap = mMapView.getMap();
            mUiSettings = aMap.getUiSettings();//实例化UiSettings类对象
        }
        LatLng latLng = new LatLng(latitude,longitude);
        MarkerOptions markerOption = new MarkerOptions();
        markerOption.position(latLng);
        aMap. moveCamera(CameraUpdateFactory.changeLatLng(latLng));//标记点居中显示
        mUiSettings.setZoomControlsEnabled(false);//隐藏大小缩放按钮
        markerOption.draggable(true);//设置Marker可拖动
        markerOption.icon(BitmapDescriptorFactory.fromBitmap(BitmapFactory
                .decodeResource(getResources(),R.mipmap.location)));
        // 将Marker设置为贴地显示,可以双指下拉地图查看效果
        markerOption.setFlat(true);//设置marker平贴地图效果
        Marker marker = aMap.addMarker(markerOption);
        marker.setRotateAngle(30);//标记点倾斜角度
    }

关于配置高德一些基础就不赘述了,我这里用的当前最新的sdk

猜你喜欢

转载自blog.csdn.net/title71/article/details/115011328