Search code examples
javascriptgoogle-mapsopenlayerszooming

Javascript OpenLayers before zoom event listener


I am trying to set up OpenLayers to not display the vector layer just before a zoom starts and make it reappear after a zoom ends. I have the zoom ends part already established like this:

map = new OpenLayers.Map('map_element', { eventListeners: { "zoomend": mapEvent}});

function mapEvent(event) {
    if(event.type == "zoomend") {
        hide_vector_layer();
        }
}

But I don't see any kind of event listener for the start of a zoom in the documentation. There is a "movestart" which covers moving, panning, and zoom. Unfortunately, I can't use the "movestart" one, because I don't want the layer to disappear during a pan. You would think there would be a "zoomstart", as there is a "zoomend".

The reason I am trying to do this, is because I don't like how the vector layer zooms at a different rate when using Google Maps as a base layer. It looks wrong, looks like all the features are inaccurate, even though they land in the right place after the zoom is complete.

Any suggestions?


Solution

  • For this purpose you should override moveTo and moveByPx methods of OpenLayers.Map for eliminate movestart event triggering for any actions except zooming.