[OpenLayers-Users] How to select on CTRL key + click
Alexandre Dube
adube at mapgears.com
Fri Nov 21 16:23:33 EST 2008
I'm been scratching my head for a while on this : how can I add select a
feature using this customized control on click + ctrl key down only ?
I've tried to add a keyMask but the checkModifiers never seems to trigger.
I tried to set it to the Control, the Handler, no success. I tried to
remove the navigation control which seemed to be the only one to trigger
checkModifiers but again no success. I must be missing something
obvious here. Any hint ?
See code below ( borrowed this one from an wfs-t example )
/**
* Class: DeleteFeature
*/
OpenLayers.Control.DeleteFeature = OpenLayers.Class(OpenLayers.Control, {
keyMask:OpenLayers.Handler.MOD_CTRL, // tried there
initialize: function(layer, options) {
OpenLayers.Control.prototype.initialize.apply(this, [options]);
this.layer = layer;
this.handler = new OpenLayers.Handler.Feature(
this, layer, {
click: this.clickFeature,
keyMask:OpenLayers.Handler.MOD_CTRL // tried there
}
);
},
clickFeature: function(feature) {
// if feature doesn't have a fid, destroy it
if(feature.fid == undefined) {
removeRoadInfoPopup(oLastHoverFeature); // HARDCODED adube
oLastHoverFeature = null; // HARDCODED adube
this.layer.destroyFeatures([feature]);
} else if (feature.state != OpenLayers.State.DELETE){
feature.state = OpenLayers.State.DELETE;
this.layer.events.triggerEvent("afterfeaturemodified",
{feature: feature});
feature.renderIntent = "select";
this.layer.drawFeature(feature);
} else {
feature.state = null;
feature.renderIntent = "default";
this.layer.drawFeature(feature);
}
},
setMap: function(map) {
this.handler.setMap(map);
OpenLayers.Control.prototype.setMap.apply(this, arguments);
},
CLASS_NAME: "OpenLayers.Control.DeleteFeature"
});
--
Alexandre Dubé
Mapgears
www.mapgears.com
More information about the Users
mailing list