[OpenLayers-Users] Events on text labels

Tamlyn Rhodes tamlyn at tamlyn.org
Fri Jul 17 07:50:49 EDT 2009


> you might want to check out:
> http://trac.openlayers.org/ticket/2148

That looks perfect! I've applied the patch and got the
symbolizers-fill-stroke-graphic.html example working but I don't quite
understand how to use the labelSelect property.

This is what I've got:

...
var textLayer = new OpenLayers.Layer.Vector('text', {
	styleMap: new OpenLayers.Style({
		label: '${label}',
		pointRadius: 5,
		labelSelect: true
	})
}); 	
textLayer.addFeatures([
	new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(0,51),
{label: 'Testing'})
]);
var control = new OpenLayers.Control.SelectFeature(textLayer, {
	onSelect: function(e){console.log(e)}
});
...

which renders a point with a label. Clicking on the point logs an
event to the (Firebug) console as expected but clicking on the label
still does nothing. I guess I've put the labelSelect option in the
wrong place?

  T.



More information about the Users mailing list