Android - Google Maps Touch and Drag Marker

2019-07-19 07:52发布

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();
        }
    });

0条回答
登录 后发表回答