KML colors are based on Style
api-doc tags that are defined either directly in the KML or using a reference to an external KML style file (similar to CSS). We use an external style file, so that the styles may be applied to multiple KML files.
这意味着在我们的 KML 中data文件中,您将找到如下条目:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.2">
<Document>
<name>Country Borders</name>
<open>1</open>
<Placemark>
<name>Russian Federation</name>
<styleUrl>kml-styles.kml#red</styleUrl>
--- etc. ---
The styleUrl
上面的标签实质上是说:去查看文件:kml-styles.kml
并找到名为:red
.
在我们的 KML 内style文件中,您将找到如下条目:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.2">
<Document>
<name>KML Styles</name>
<open>1</open>
<Style id="red">
<LineStyle>
<color>7da00000</color>
<width>1</width>
</LineStyle>
<PolyStyle>
<color>7f0000ff</color>
</PolyStyle>
</Style>
<Style id="green">
<LineStyle>
<color>FFFF00</color>
<width>1</width>
</LineStyle>
<PolyStyle>
<color>7f00aa00</color>
</PolyStyle>
</Style>
--- etc. ---
It's important to note that KML colorapi-doc definitions include eight hex digits within their definition; two more digits than what is customary for other color definitions, because the first two hex digits define the color opacity (alpha).
The example at the KML Style
api-doc (same as the link at the top), also shows how styles may be defined directly within the KML file that contains the data.