Created
July 19, 2011 02:43
-
-
Save cspanring/1091204 to your computer and use it in GitHub Desktop.
custom openlayers click handler compatible with touch events
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create click handler | |
OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, { | |
defaultHandlerOptions: { | |
'single': true, | |
'double': false, | |
'pixelTolerance': 0, | |
'stopSingle': false, | |
'stopDouble': false | |
}, | |
initialize: function(options) { | |
this.handlerOptions = OpenLayers.Util.extend( | |
{}, this.defaultHandlerOptions | |
); | |
OpenLayers.Control.prototype.initialize.apply( | |
this, arguments | |
); | |
this.handler = new OpenLayers.Handler.Click( | |
this, { | |
'click': this.trigger | |
}, this.handlerOptions | |
); | |
} | |
}); | |
// Create click control | |
var clickControl = new OpenLayers.Control.Click( { | |
trigger: function(e) { | |
/* do your thing */ | |
} | |
}); | |
map.addControl(clickControl); | |
clickControl.activate(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment