This is a static archive of our old OSM Help Site. Please post any new questions and answers at community.openstreetmap.org.

[closed] how to add an “onclick” function to a marker?

1

I have a marker such as this

var feature = new OpenLayers.Feature.Vector(
                      new OpenLayers.Geometry.Point( lng,lat ).transform(epsg4326, projectTo),
                      {description:'something'} ,
                      {externalGraphic: 'somepic.png', graphicHeight:34, graphicWidth: 21, graphicXOffset:0,   
                                      graphicYOffset:0 }); 
vectorLayer.addFeatures(feature);
map.addLayer(vectorLayer);

i was wondering if there is a way to add onclick function to the markers, so an example use would be something like

feature.onClick(function (){
   alert("clicked");
});

asked 31 Mar '12, 19:03

bernabasd's gravatar image

bernabasd
16222
accept rate: 0%

closed 31 Mar '12, 20:01

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273

The question has been closed for the following reason “Question is off-topic or not relevant” by Frederik Ramm 31 Mar ‘12, 20:01


One Answer:

0

This is an OpenStreetMap help forum but your question is a general OpenLayers question. The OpenLayers "users" mailing list at http://lists.osgeo.org/mailman/listinfo/openlayers-users/ would be a good place to ask such a question.

answered 31 Mar '12, 20:01

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273
accept rate: 23%