On 03/24/2010 01:52 PM, Frost89 wrote: > Hi list > > In my map I have added a vector layer and a drawFeature control. > The drawFeature is set to draw points, and works without problems. > > Now, I would like to assign a text-label to the point's style. > The text in the label should be defined by the user (through a prompt() or > other alternatives). >
Try and set the text in the feature's properties: feature.properties.text = mytext; and then add a style to the layer you place the feature in: var style = new OpenLayers.Style({ label: "${text}", }); (a bit confused about your code snippet, is the event in featureAdded indeed the created feature?) -atle > So I was thinking about settings this value in the "featureAdded" event of > the drawFeature control, but I can't quite figure out how to do this. > When I try to do it like this... > var point = new OpenLayers.Control.DrawFeature( > vectorLayer, > OpenLayers.Handler.Point, > { > type: OpenLayers.Control.TYPE_TOOL, > featureAdded: function(event) { > event.style.label = 'test'; > redliningLayer.drawFeature(event); > } > } > ); > > ... I just get an error message: > event.style is null > So if anyone has an idea of how to do this, it would be appreciated :) > > - Kristian Frost > -- Atle Frenvik Sveen GIS Konsulent Geomatikk IKT AS tlf: 45 27 86 89 atle.frenvik.sv...@geomatikk.no
_______________________________________________ Users mailing list Users@openlayers.org http://openlayers.org/mailman/listinfo/users