[OpenLayers-Users] Can not Extract KML Attribute
Arnd Wippermann
arnd.wippermann at web.de
Sat Dec 1 07:58:05 PST 2012
It seems, that the propertyStyles for label have to be set.
something like this:
pois["styleMap"]["styles"]["default"]["propertyStyles"] = {"label":true};
Example:
http://gis.ibbeck.de/ginfo/apps/OLExamples/OL212/kml_csv_data_layer/kml_csv_
data_layer.asp?propertyStyles=true
Regards,
Arnd
gis.ibbeck.de
_____
Von: openlayers-users-bounces at lists.osgeo.org
[mailto:openlayers-users-bounces at lists.osgeo.org] Im Auftrag von
reinaldo at geodesign.com.br
Gesendet: Freitag, 30. November 2012 13:38
An: openlayers-users at lists.osgeo.org
Betreff: [OpenLayers-Users] Can not Extract KML Attribute
OL Users,
Could some one please help?
I can not extract attributes in a KML file. Here is my KML:
<?xml version="1.0" encoding="utf-8" ?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Folder>
<name>ba_uf</name>
<Schema name="ba_uf" id="ba_ufID">
<SimpleField type="string" name="ID"></SimpleField>
<SimpleField type="string" name="Regiao"></SimpleField>
<SimpleField type="string" name="State"></SimpleField>
<SimpleField type="float" name="Area"></SimpleField>
</Schema>
<Placemark>
<Style>
<LineStyle><color>ff0000ff</color></LineStyle>
<PolyStyle><fill>0</fill></PolyStyle>
</Style>
<ExtendedData>
<SchemaData schemaUrl="#ba_ufID">
<SimpleData name="ID">2909901</SimpleData>
<SimpleData name="Regiao">Nordeste></SimpleData>
<SimpleData name="State">BAHIA></SimpleData>
<SimpleData name="Area">0</SimpleData>
</SchemaData>
</ExtendedData>
<Polygon>
<tessellate>1</tessellate>
<outerBoundaryIs>
<LinearRing>
<coordinates>
-39.76265494838268,-12.27246488227016,0
-39.48325151827876,-12.09283133762983,0
-39.41905766787695,-11.8699639552835,0
-39.36482198574752,-11.65858652001503,0
-39.76422342556302,-11.64471479218556,0
-40.04350054605078,-11.82438907570092,0
-40.01005372231482,-12.1350573465942,0
-39.76265494838268,-12.27246488227016,0
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
</Folder>
</Document>
</kml>
This what I am using to extract and style the attributes:
...
new OpenLayers.Layer.Vector("ESTADO DA BAHIA", {
strategies: [new OpenLayers.Strategy.Fixed()],
protocol: new OpenLayers.Protocol.HTTP({
url: "kml/ba_uf_900913a.kml",
format: new OpenLayers.Format.KML({
extractStyles: false,
extractAttributes: true,
srsName: "EPSG:900913"
})
}),
style: {
fillColor: "#ffffff",
fillOpacity: 0,
strokeWidth: 1,
strokeColor: "#0000ff",
strokeOpacity: 1,
label: "${State}",
fontColor: "#ffffff",
fontFamily: "sans-serif",
fontSize: "15px",
fontWeight: "bold"
}
...
I want the attribute for State to be rendered on the map, but I only get
${State} rendered.
I've tried additng <value></value> and label: "${State}" or label:
"${State.value}" . I get either ${State} or ${State.value} rendered on the
map, but never the actual attribute, which is BAHIA.
I just can´t get it to work. Could someone help please?
Thanks a lot in advance.
Reinaldo
_____
Reinaldo Escada Chohfi
Sócio Gerente
GeoDesign Internacional
www.geodesign.com.br
Tel./Fax: (12) 3153-5115
Inteligência e Tecnologia Espacial de Ponta
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20121201/8000024a/attachment.html>
More information about the Users
mailing list