Pan event for Google Maps?

There are some event listeners like mouseover, mouseout and click to use them on Google Map, but is there an event that responds when the user pans or zooms the map?


I used "center_changed" but it didn't work as I hoped! If I move the mouse over the map and then pan the map, the event fires, but the event fires all the time, even if I don't pan, just move the mouse cursor over the map. The mouse cursor is a fist, not a hand, all the time !? What's wrong?


source to share

2 answers

Yes there is.

pan  -> 'center_changed'
zoom -> 'zoom_changed'




You can use the mousedown and mouseup events to track if the mouse is being used to pan the map. If the mouse is not down, then the center_changed event is triggered by the user pressing the panning button:

//only reload on center_changed if the mouse is not down. This is equivalent to panning
this.addListener("center_changed", function() {
    if (!this.mouseDown) {
        //user has clicked the pan button

this.addListener("mouseup", function() {
    this.mouseDown = false;

this.addListener("mousedown", function() {
    this.mouseDown = true;




All Articles