-1

Whenever I am dragging my marker, the getPosition is being console logged every 0.1s while the element is being dragged. How can I make it only console log when it's being stopped dragged? I want the same effect as .getRadius() works, it only console logs it when the radius is being changed once.

Unwanted effect, I want to log it only once after position change

  marker.Circle.addListener('center_changed', function() {
          console.log(marker.getPosition())
        })
Boosa
  • 71
  • 5

1 Answers1

2

Instead of using the center_changed event, use the dragend one.

marker.Circle.addListener('dragend', function() {
   console.log(marker.getPosition())
});

https://developers.google.com/maps/documentation/javascript/reference/polygon#Circle.dragend

Also it's actually a Circle, not a Marker, that's being dragged. Only Circle and Map objects have the center_changed event. So it looks like it's a circle attached to your marker.

duncan
  • 30,730
  • 12
  • 76
  • 95