OpenLayers 3 : DragZoom, change shortcut from [Click + Shift] to [Click + Ctrl] -
i'm trying change default behavior of ol3 on dragzoom event: want feature, default configured on [click + shift], working instead [click + ctrl].
do have idea of how perform that?
already consulted online doc: http://openlayers.org/en/latest/apidoc/ol.interaction.dragzoom.html
seems "condition" property, can't figure out how that.
the "condition" value has function called when event occurs. openlayers doesn't come ol.events.condition.ctrlkeyonly
, define own. you'd need disable default dragzoom interaction first, add own:
var interactions = ol.interaction.defaults({ shiftdragzoom: false }); interactions.push(new ol.interaction.dragzoom({ duration: 200, condition: function(mapbrowserevent) { var originalevent = mapbrowserevent.originalevent; return ( originalevent.ctrlkey && !(originalevent.metakey || originalevent.altkey) && !originalevent.shiftkey); } }));
see in action in jsfiddle demo.
Comments
Post a Comment