我已经看了这么久了,我再也看不到它了。
它看起来像有效的 KML 样式,URI 看起来不错,但它不起作用。
<?xml version="1.0" encoding="utf-8"?>
<kml xmlns="http://earth.google.com/kml/2.2">
<Document>
<name>Style Test</name>
<PolyStyle>
<color>776d8f77</color>
<outline>0</outline>
</PolyStyle>
<PolyStyle id="counties">
<color>776d8f77</color>
<outline>0</outline>
</PolyStyle>
</Document>
</kml>
此文件由 KML 引用:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2"><Document>
<Placemark>
<name>Viburnum australe US Distribution</name>
<styleUrl>/_/maps/style.kml#counties</styleUrl>
<Polygon> ....
为什么两种样式都没有应用?
TIA.....
<PolyStyle>
样式元素在父元素<Style>
元素的上下文之外无效。特征(例如地标)不能直接引用 PolyStyle 元素,而只能通过 Style 或 StypeMap 引用或内联元素来引用。此外,使用正确的 KML 命名空间 URL 作为http://www.opengis.net/kml/2.2
而不是http://earth.google.com/kml/2.2
。
而是像这样重写"style.kml"文件:
<?xml version="1.0" encoding="utf-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<name>Style Test</name>
<Style id="s1">
<PolyStyle>
<color>776d8f77</color>
<outline>0</outline>
</PolyStyle>
</Style>
<Style id="counties">
<PolyStyle>
<color>776d8f77</color>
<outline>0</outline>
</PolyStyle>
</Style>
</Document>
</kml>
现在,对该样式的引用将起作用:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Placemark>
<name>Viburnum australe US Distribution</name>
<styleUrl>style.kml#counties</styleUrl>
<Polygon>....
Google 提供了其他 KML 文件使用的样式的 KML 文档示例:
http://kml-samples.googlecode.com/svn/trunk/kml/Style/styles.kmlhttp://kml-samples.googlecode.com/svn/trunk/kml/Style/remote-style.kml