android - 百度地图拖拽图标后原来位置的图标还在?
天蓬老师
天蓬老师 2017-04-17 17:34:08
0
2
590

marker的remove()方法如何移除原来位置的标注?

  //地图标注
    private void initMark() {
        //定义Maker坐标点
        LatLng point = new LatLng(39.963175, 116.400244);
//构建Marker图标
        BitmapDescriptor bitmap = BitmapDescriptorFactory
                .fromResource(R.drawable.icon_marka);
        OverlayOptions option = new MarkerOptions()
                .position(point)
                .icon(bitmap);
//构建MarkerOption,用于在地图上添加Marker
        OverlayOptions options = new MarkerOptions()
                .position(point)  //设置marker的位置
                .icon(bitmap)  //设置marker图标
                .zIndex(9)  //设置marker所在层级
                .draggable(true);  //设置手势拖拽
//在地图上添加Marker,并显示
        mBaiduMap.addOverlay(option);
        marker = (Marker) (mBaiduMap.addOverlay(options));
        //调用BaiduMap对象的setOnMarkerDragListener方法设置marker拖拽的监听

        mBaiduMap.setOnMarkerDragListener(new BaiduMap.OnMarkerDragListener() {
            public void onMarkerDrag(Marker marker) {
                //拖拽中
                log("拖拽中");
            }
            public void onMarkerDragEnd(Marker marker) {
                //拖拽结束
                log("拖拽结束");
            }
            public void onMarkerDragStart(Marker marker) {
                //开始拖拽
                log("开始拖拽");
            }
        });

    }
天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(2)
阿神
  1. Tell me your own way, set your icon in the center of your layout file

  2. The icon does not move and is always at the center of the current scene. Baidu Map can be moved

伊谢尔伦

mBaiduMap.addOverlay(option);
marker = (Marker) (mBaiduMap.addOverlay(options));

I created it repeatedly

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template