Google Maps marker is set to drag and drop, but cannot be dragged

API v3

I have a strange marker issue:

The marker that I place on the map is set to drag and drop, WebInspector reports it as being draggable, but I still can’t drag it. The cursor does not change when I look at the marker.

The basemap is dragged and it works.

On another page with a different setting (fewer layers) but with the same javascript, it works as expected (so that I can drag it).

I also made the marker clickable and associated the event with it, and this works great. The cursor also changes when you hover over the mouse.

I'm out of options ... Why can't I drag it? Could this be related to some zIndex or layer positioning? As far as I can see, the map has a higher zIndex than all other layers ....

// display map

geocoder.geocode( { 'address':address }, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { // map options var mapOptions = { zoom: 14, center: results[0].geometry.location, panControl: false, zoomControl: true, zoomControlOptions: { style: google.maps.ZoomControlStyle.SMALL }, mapTypeControl: false, scaleControl: false, streetViewControl: false, mapTypeId: google.maps.MapTypeId.ROADMAP, scrollwheel: false }; // render map map = new google.maps.Map(J('#'+mapElementId)[0], mapOptions); // set marker marker = new google.maps.Marker({ clickable: true, draggable: true, icon: markerImage, shadow: markerShadow, shape: markerShape, map: map, position: results[0].geometry.location }); google.maps.event.addListener(marker, 'click', function () { alert('marker clicked'); }); google.maps.event.addListener(marker, 'dragend', function () { alert('marker dragged') map.setCenter(marker.getPosition()); J('input[name=coordinates]').val(marker.getPosition()); J('input[name=address]').val(''); }); J('input[name=address]').val(results[0].formatted_address); } }); 
+4
source share
2 answers

you have draggable: false,

change it to true

see here: http://jsfiddle.net/RASG/vA4eQ/

+5
source

Try the following:

  map.setOptions({draggable: true}); 
0
source

Source: https://habr.com/ru/post/1441842/


All Articles