[OpenLayers-Users] Click on OpenLayers.Feature.Vector

Christoph Lingg christoph at lingg.eu
Thu Feb 25 03:52:29 EST 2010


Hello!

I changed from GoogleMap to OpenLayers, and although I enjoy to use the opensource equivalent, sometimes I feel lost in the OL documentation ;-)

Would anyone be so kind and could give me hint how to achieve this very low level problem: I have a Vector Layer (I can't use marker class as I use the dragging feature as well) to which I add some Feature Vector, that are displayed on the map. What I need now is triggering an event when a feature was clicked. Very basically my code looks like this:
> layer = new OpenLayers.Layer.Vector("layer");
> map.addLayers([layer]);
> ftr = new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(lon, lat), null, styleMarker); // an icon
> layer.addFeatures([ftr]);
I tried different approaches that never worked out! What is the right way to go?

Thank you in advance for any help!

Christoph 






More information about the Users mailing list