NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

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


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.

permanent link

answered 31 Mar '12, 20:01

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273
accept rate: 23%

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×122
×37
×10

question asked: 31 Mar '12, 19:03

question was seen: 8,793 times

last updated: 31 Mar '12, 20:01

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum