Reputation: 1744
I have an OpenLayers map with two vector layers. Both of them contain marker.
With help of the following link, I managed to get a select-handler on both layers. http://openlayers.org/dev/examples/select-feature-multilayer.html
This select-handler fires the same function for marker on both layers. But how can I differ, on which layer the selected is positioned?
Upvotes: 3
Views: 764
Reputation: 3656
In OpenLayers,handler event triggers on single viewport or map canvas.Therefore,you should attach event (feature selection and feature unselection) on each layer.If you follow the code,in example page,it is so clear that they use the same event but different places where you may alter your own code.
vectors1.events.on({
"featureselected": function(e) {
showStatus("selected feature "+e.feature.id+" on Vector Layer 1");
},
"featureunselected": function(e) {
showStatus("unselected feature "+e.feature.id+" on Vector Layer 1");
}
});
for vectors2 the same event is attached.If you're looking for which layer the feature is placed as above code says so.
Upvotes: 4