Android - Google Maps Touch and Drag Marker

六眼飞鱼酱① 提交于 2019-12-11 02:08:58

问题


How would I go through moving a marker on a Map Activity without having to long click and hold that marker until it receives focus?

I just want to touch and drag, but it takes around 1-2 secs before it receives focus and fires drag event.

here's my code:

   mMap = googleMap;
    mMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
    mMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() {
        @Override
        public void onMapClick(LatLng latLng) {

            Marker marker = mMap.addMarker(new MarkerOptions()
                    .position(latLng)
                    .draggable(true));

            markers.add(marker);

            updateUI();
        }
    });

    mMap.setOnMarkerDragListener(new GoogleMap.OnMarkerDragListener() {
        @Override
        public void onMarkerDragStart(Marker marker) {

            updateUI();
        }

        @Override
        public void onMarkerDrag(Marker marker) {
            updateUI();
        }

        @Override
        public void onMarkerDragEnd(Marker marker) {
            updateUI();
        }
    });

来源:https://stackoverflow.com/questions/39561108/android-google-maps-touch-and-drag-marker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!