[OpenLayers-Users] Events priority

Alex zeitalex at googlemail.com
Mon Feb 21 07:37:48 EST 2011


Dear all,
We have point layer on top of LineString layer. For both layers the Popup
should appear on 'featureselected' event. But if user clicks on Point the
Popup for the line should not appear.
The setup is:
Ubuntu
Tomcat 6
Geoserver 2.0.0
OpenLayers 2.10
GeoExt 0.7

We tried the code below, but it is not always working. Sometimes both popups
appear while clicking on point feature. It seems that sometimes
lineControl’s 'featureselected' event is triggered before pointControl’s
'featureselected' event. Does anybody know why?
Any help would be highly appreciated.

var ShowLinePopup = true;
var lines = new OpenLayers.Layer.WMS(…);
var points = new OpenLayers.Layer.WMS(…);

lineControl = new OpenLayers.Control.GetFeature({
    protocol: OpenLayers.Protocol.WFS.fromWMSLayer(lines),
    box: false,
    toggleKey: "ctrlKey",
    maxFeatures: 1
});

pointControl = new OpenLayers.Control.GetFeature({
    protocol: OpenLayers.Protocol.WFS.fromWMSLayer(points),
    box: false,
    toggleKey: "ctrlKey",
    maxFeatures: 1
});

lineControl.events.register('featureselected', this, function(e) {
    if (showLinePopup){showLinePopupFunc();}
showLinePopup = true;
});

pointControl.events.register('featureselected', this, function(e) {
    showLinePopup = false;
    showPointPopupFunc();
});

new Ext.Viewport({…, layers: [lines, points,], …});

map.addControl(lineControl);
map.addControl(pointControl);
lineControl.activate();
pointControl.activate();
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20110221/8855ace0/attachment.html


More information about the Users mailing list