I am sure that impulse can at least be counteracted. Someone please correct me if I am wrong! For simplicity, for example, suppose your map container has a width of 100vw and a height of 100vh . Do you just call getCenter() on the function called by the mouseup event, and then use these coordinates immediately with setCenter() ?
function initMap(){ ... var win = window; google.maps.event.addDomListener(win, 'mouseup', setCoords); function setCoords(){ var x = myMap.getCenter(); var lat = x.lat(); var lng = x.lng(); myMap.addListener('center_changed', function(lat, lng){ myMap.setCenter(new google.maps.LatLng(lat, lng)); }; };
Actually, this code works, but the kicker consists in the fact that it works only once, until the browser seems to be overloaded, and throws an Uncaught RangeError error : maximum call stack size .
Not sure what to do now.
Read more about it here .
user2230470
source share