javascript - Drag rotate interaction in OpenLayers 3 on Linux -
i'd use openlayers 3 rotation interaction on browser running under linux. allows map rotate dragging whilst pressing alt , ctrl. works fine on windows, not in redhat 6u2 , other distributions alt key reserved x-windows drag window behaviour.
firstly customized dragrotate ol.events.condition.shiftkeyonly
, worked, conflicted zoom-box functionality, i.e. draws blue zoom box whilst rotating.
var map = new ol.map({ layers: [ new ol.layer.tile({ source: new ol.source.osm() })], target: 'map', view: new ol.view({ center: [-25860000, 4130000], zoom: 10 }), interactions: ol.interaction.defaults().extend([new ol.interaction.dragrotate({ condition: ol.events.condition.shiftkeyonly })]) });
i'd retain shift-drag zoom box , use other key/combination, maybe 'r+shift'? i've tried customize condition. see jsfiddle
var customcondition = function(mapbrowserevent) { return false; // todo }; var map = new ol.map({ layers: [ new ol.layer.tile({ source: new ol.source.osm() })], target: 'map', view: new ol.view({ center: [-25860000, 4130000], zoom: 10 }), interactions: ol.interaction.defaults().extend([new ol.interaction.dragrotate({ condition: customcondition })]) });
i can't find in api implementing custom conditions other ol.events , mapbrowserevent documentation. using debugger can't find attributes in structure or nested originalevent contains keycode etc.
- how can implement customcondition function detect when given key pressed during drag?
- is there other way of implementing drag rotate works in linux
here custom condition - ctrl + shift:
ol.events.condition.custom = function(mapbrowserevent) { var browserevent = mapbrowserevent.originalevent; return (browserevent.ctrlkey && browserevent.shiftkey); }; var map = new ol.map({ layers: [ new ol.layer.tile({ source: new ol.source.osm() })], target: 'map', view: new ol.view({ center: [-25860000, 4130000], zoom: 10 }), interactions: ol.interaction.defaults().extend([new ol.interaction.dragrotate({ condition: ol.events.condition.custom })]) });
Comments
Post a Comment