[OpenLayers-Users] disable double click

Ian Erickson ierickson at analygis.com
Tue Jul 3 11:50:46 EDT 2007


A nice way to do this is to create your own class inheriting from the 
OpenLayers.Control.Navigation class.  Here's what I would recommend...

In a new Javascript file....AM_Navigation.js

//----------------------------------------------------------
/**
 * @class
 *
 * @requires OpenLayers/Control/Navigation.js
 */
OpenLayers.Control.AM_Navigation = OpenLayers.Class.create();
OpenLayers.Control.AM_Navigation.prototype =
  OpenLayers.Class.inherit( OpenLayers.Control.Navigation, {

    /**
    * @param {Event} evt
    */
    defaultDblClick: function (evt) {
        var newCenter = this.map.getLonLatFromViewPortPx( evt.xy );
        //this.map.setCenter(newCenter, this.map.zoom + 1);
        this.map.setCenter(newCenter, this.map.zoom);
        OpenLayers.Event.stop(evt);
        return false;
    },

    /** @final @type String */
    CLASS_NAME: "OpenLayers.Control.AM_Navigation"
});

//----------------------------------------------------------

When you initialize your map, initialize it with your new map navigation 
control....

//----------------------------------------------------------
...
    <script src="/lib/OpenLayers/Control/AM_Navigation.js"></script>
...
            map = new OpenLayers.Map( 'map', {controls: [new 
OpenLayers.Control.AM_Navigation(), new OpenLayers.Control.PanZoom(), 
new OpenLayers.Control.ArgParser()]} );
...
//----------------------------------------------------------

Ian Erickson
AnalyGIS, LLC
http://www.analygis.com




fadi maali wrote:

> Hi all,
>
> double clicking a map will zoom it in.
> Can I disable this double click handling and how?
>
> Many thanks
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Users mailing list
>Users at openlayers.org
>http://openlayers.org/mailman/listinfo/users
>  
>




More information about the Users mailing list