[OpenLayers-Dev] help with unregistring Layer.Text "markerClick" event

Paul Spencer pspencer at dmsolutions.ca
Thu Apr 23 13:09:30 EDT 2009

Not sure what the status of Text layer is, but the latest version of  
OpenLayers (2.8) includes shiny new support for labels in vector  
layers which I have recently been playing with.

var vectorLayer = new OpenLayers.Layer.Vector('Vectors');
vectorLayer.events.register(featureselected, null, featureSelected);
map.addControl(new OpenLayers.Control.SelectFeature());

/* create a vector feature with a point geometry at the appropriate  
  * location and set its style to include a label property with the  
text you want
  * to display on the map
var feature = new OpenLayers.Feature.Vector(
     new OpenLayers.Geometry.Point(lon, lat),
     {label: text}


function featureSelected(feature) {
   //handle the feature being selected

You can also label other types of vector features (lines, polygons  
etc) and you can play with the style to add a marker image  
(externalGraphic) and other fancy things.



On 23-Apr-09, at 12:44 PM, Julio RENELLA wrote:

> Hi everybody !
> Please, can someone help me to find a solution (if possible) for this
> problem :
> At this time, I have a map with only one event (the mouse-click) in
> order to produce
> a popup info of a place (thanks to the coordinates I pick through the
> mouse-click event).
> Now I need to insert a TEXT layer (maybe many of you doesn't use it
> since long time)
> with it's own markers.
> The problem is that I would like to keep my first event (mouse-click)
> over the "markerClick"
> event of the Text layer... Better, I would like to unregister (or
> forbid) this "markerClick" event.
> Do you think it's possible to do such a thing ?
> Or maybe it can't be done beaucause the Text layer wasn't made for  
> this
> kind of use... ?
> An alternative can be replacing the Text layer by a GML layer. This  
> way
> I don't disrupt
> the event that I need... But only in the case that my problem do not
> have solution !
> Can someone help me with an advice ?
> Thanks !!!
> _______________________________________________
> Dev mailing list
> Dev at openlayers.org
> http://openlayers.org/mailman/listinfo/dev


    Paul Spencer
    Chief Technology Officer
    DM Solutions Group Inc

More information about the Dev mailing list