[OpenLayers-Users] Re: problem - map errorneously auto zoom in when continuously clicking on a marker

shitake83 shitake83 at googlemail.com
Tue Jun 14 12:23:18 EDT 2011


Hi.
You could "restrict" double-clicking to zoom, by removing the control from
the map.
Then you wouldn't be able to double-click to zoom, but you could still
scroll the mousewheel to zoom in or out, or just let your users use the
slider.

The double click function resides in OpenLayers.Control.Navigation
http://dev.openlayers.org/docs/files/OpenLayers/Control/Navigation-js.html

This is the original implementation:

defaultDblClick: function (evt) {
        var newCenter = this.map.getLonLatFromViewPortPx( evt.xy ); 
        this.map.setCenter(newCenter, this.map.zoom + 1);
}
    

To disable doubleClick add this:
__________________________
var Navigation = new OpenLayers.Control.Navigation({
defaultDblClick: function(event) { return; }
});

map.addControl(Navigation);


You have to call the addControl method, otherwise the standard
defaultDblClick function wont be overwritten. 

I havent tried it, but you could change the implementation in a way, that it
checks to see if you have hit a marker, which would mean that a popup would
fire up or if you were trying to induce a zoom with the dblClick. If a
marker was hit, dont take the dblClick as a "dblClick to zoom in" but as a
"doubleClickToShowPopup".


var Navigation = new OpenLayers.Control.Navigation({
defaultDblClick: function(evt) {
if(determineDblClick() == 0)
      {
        dblClickToZoom();
      }
else{ doubleClickToShowPopup(); }
}
return;}


Cheers.Shitake.

--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/problem-map-errorneously-auto-zoom-in-when-continuously-clicking-on-a-marker-tp6474469p6474795.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.


More information about the Users mailing list