Thanks! That's just what I have done! It works great! But I didn't use the attributes property: I don't need to save the label text in a database. I store the written text directly inside the 'label' property. It's also useful to add a 'labelSelect' property with 'true' to drag the text once written. It could be interesting to create an OpenLayers example about this. It is a very simple tip, but quite useful.

PS: it works also with GeoExt and a FormPanel to write the text.

Geoffrey


On Tue, 30 Aug 2011 13:50:38 +0200, Frost89 <[email protected]> wrote:

Try adding a drawfeature control, that prompts for a text and sets it as the
label. Should be something like this this:

var control = new OpenLayers.Control.DrawFeature(
  layer,
  OpenLayers.Handler.Point, {
    featureAdded: function(feature) {
      feature.attributes.text = prompt('Write here:', '');
      feature.style.label = feature.attributes.text;
      feature.layer.drawFeature(feature);
    }
  }
);

-----
Best regards,
Kristian Frost
Webintegrator
Orbicon Informatik
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Write-text-on-a-map-tp6741079p6741765.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users


--
Using Opera's revolutionary email client: http://www.opera.com/mail/
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

Reply via email to