[OpenLayers-Users] showing textlabels on a KML layer

Thomas PAPIN thomas.papin at gmail.com
Thu Aug 26 03:26:35 EDT 2010


You can do something like:

styleMap = new OpenLayers.StyleMap({'default':{
                        label : "${label}",
                        fontColor: "${fontColor}",
                        fontSize: "11px",
                        labelAlign: "${labelAlign}",
                        pointRadius: 2,
                        labelXOffset : "${labelX}",
                        labelYOffset : "${labelY}"
                    }});

GMLlayer = new OpenLayers.Layer.GML("Layer name, kml_url,
 {
                    format: OpenLayers.Format.KML,
                                                    formatOptions: {
                                                        extractAttributes:
true,
                                                        maxDepth: 2
                                                        },
                                                    styleMap: styleMap
                                                });

And a KML like that:

<kml xmlns="http://www.opengis.net/kml/2.2">
  <Document>
    <name>Date</name>
    <description>Date</description>
      <Placemark>
         <label>24 Jan, 13h</label>
         <labelAlign>center</labelAlign>
         <labelX>0</labelX>
         <labelY>10</labelY>
         <Point>
           <coordinates>70.0,-30</coordinates>
         </Point>


2010/8/25 Tim Alder <tim.alder at s2002.tu-chemnitz.de>

> Hello, is there a way to show labeltext on a layer that based on KML?
> Where can I found a good example for this?
>
> The next step would be perhaps than a solution to prevent coolisions
> between this labeltext but this seems really complicate.
>
>
> Greetings Kolossos
>
> P.S: To my person: I'm working on the cooperation between Wikipedia and
> OpenStreetMap.
> First result:
>
> http://toolserver.org/~kolossos/openlayers/kml-on-ol.php?zoom=10&lat=48.15841&lon=11.42421&lang=en&layers=B00TT<http://toolserver.org/%7Ekolossos/openlayers/kml-on-ol.php?zoom=10&lat=48.15841&lon=11.42421&lang=en&layers=B00TT>
> Some cartographs means now that it would be better to show optional also
> textlabels on map.
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20100826/cf813cd8/attachment.html


More information about the Users mailing list