I would have an openlayers vector layer with features scattered all over the map. I want to be able to click on a feature and have a message display.
I'm not sure if there is a way to add a listener/handler to each feature.
Any ideas?
Add SelectFeture control:
var selectFeature = new OpenLayers.Control.SelectFeature(vector_layer);
map.addControl(selectFeature);
selectFeature.activate();
After that you can listen to select/unselect events on vector layer:
vector_layer.events.on({
'featureselected': function(feature) {
//display your message here
},
'featureunselected': function(feature) {
//hide message
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With