I have a map with features. I want to klick on features and react to 'featureselected'. I also want to be able to click somewhere else in the map.
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
);
},
trigger: function(evt) {
// do things
}
});
var click = new OpenLayers.Control.Click();
selectControl = new OpenLayers.Control.SelectFeature(vector);
_map.addControl(selectControl);
selectControl.activate();
_map.addControl(click);
click.activate();
vector.events.on({
'featureselected': onSelect,
When the feature is clicked, I DO NOT want to call the click function for the map. What do I have to call in onSelect to prevent the event from propagating, bubbling? Right now both functions are called when I click on a feature. I tried OpenLayers.Event.stop(evt), found evt.cancelBubble, cannot find evt.Bubbles
Thanks a lot, Ropo
I have an OpenLayers Map with an MouseOver-Control (Vector), with a SelectFeature (Vector) and also a Click-Event that searches GetFeatureInfo-Requests a the click position if nothing was found.
It might help you to add your Click-Control before the selectControl.
My init-function approximately looks like this in the following order:
oMouseOverCtrl = new OpenLayers.Control.SelectFeature( oMouseOverVectorArray, { ... });
oMapObj.addControl( oMouseOverCtrl );
oMouseOverCtrl.activate();
oMouseClickControl = new OpenLayers.Control.SelectFeature( oMouseOverVectorArray, { ... });
oMapObj.addControl( oMouseClickControl );
oMouseClickControl.activate();
oMouseClickControlInfotool = new OpenLayers.Control.WMSGetFeatureInfo({...});
oMapObj.addControl( oMouseClickControlInfotool );
oMouseClickControlInfotool.activate();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.