[OpenLayers-Users] Events on text labels
Paul Spencer
pagameba at gmail.com
Fri Jul 17 08:27:33 EDT 2009
The patch is pretty simple. From my tests, the textbox object in SVG
and the VML equivalent do trigger an event when clicked. The event
from the click is passed to the rendered to get the feature from the
event and the code that does this checks for a couple of properties on
the target of the event - which were not there for the textbox. The
patch just adds those properties to those elements so that the
associated feature is selected when the text is clicked.
The patch does not change how the style map works and I am unfamiliar
with labelSelect (having worked with Styles a lot recently, I don't
recall that being a property of styles?). It is possible that the
patch needs to be updated to change some aspect of the textbox when it
is selected, if someone can point out what needs to be done, I'd be
happy to update it.
Cheers
Paul
On 17-Jul-09, at 7:52 AM, bartvde at osgis.nl wrote:
> Hi Tamlyn,
>
> please always cc the list. I am unfamiliar with the contents of this
> patch
> (I just knew of its existance), but maybe Paul or Andreas can shine a
> light on this?
>
> Best regards,
> Bart
>
>>> 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.
>>
>
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
More information about the Users
mailing list