Search code examples
javascripteventsevent-handlingopenlayersmouseup

OpenLayers MouseUp Event - Mouse Still Drags Map


I register a mouse up event with an open layers map and the event gets fired when I do a mouse up, but the map keeps moving with the mouse. For some reason registering this event caused the map to keep panning after I do a mouse up.

Here is the function:

var refreshCities = function(evt) { 
                       console.log("refreshing cities list"); 
                    };

Here is the event registration:

CitiesDisplay.events.register("mouseup", null, refreshCities);

After I saw this problem I tested the other types of events ("mousedown", "click", ...) but they don't have the same problem. I haven't found anything else online in solving this problem. Thank you for any help.


Solution

  • I solved the problem. I needed to be registering this type of event: "moveend". Here is what would be changed in the registration:

    CitiesDisplay.events.register("moveend", null, refreshCities);
    

    Now everything seems to work as normal. This link is what helped me most: http://dev.openlayers.org/docs/files/OpenLayers/Layer-js.html#OpenLayers.Layer.events