【发布时间】:2018-06-25 13:29:46
【问题描述】:
请告诉我哪一个是“作为 KML 文件格式的正确行为”。
您可能知道,KML 的
16.9 公里:颜色类型
表达式的顺序是aabbggrr,其中aa=alpha(00到ff); bb=蓝色(00 到 ff); gg=绿色(00 到 ff); rr=红色(00 到 ff)。 http://docs.opengeospatial.org/is/12-007r2/12-007r2.html
所以,<color>7f0000ff</color> 应该是红色的。
示例1:
使用此 KML 文件,Google 地球和 Google Maps API (KmlLayer) 可以正确绘制红色折线。
<?xml version="1.0" encoding="utf-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Style id="globalStyles">
<LineStyle id="line">
<color>7f0000ff</color>
<width>4</width>
</LineStyle>
</Style>
<Placemark>
<styleUrl>#globalStyles</styleUrl>
<LineString>
<tessellate>1</tessellate>
<coordinates>-14.405821,-7.963539 -14.381448,-7.975707</coordinates>
</LineString>
</Placemark>
</Document>
</kml>
https://jsfiddle.net/wf9a5m75/xnw0hvvf/6/
示例2:
但是,对于此 KML 文件,Google Maps API 会绘制一条蓝色线,但 Google Earth 仍会绘制一条红色折线。
<?xml version="1.0" encoding="utf-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Style id="globalStyles">
<LineStyle id="line">
<color>7f0000ff</color>
<width>4</width>
</LineStyle>
</Style>
<Placemark>
<name>runway</name>
<styleUrl>#globalStyles</styleUrl>
<Style>
<LineStyle>
<!--
Coloring is implicitly merged from the global style, width is
explicitly overridden.
-->
<width>10</width>
</LineStyle>
</Style>
<LineString>
<tessellate>1</tessellate>
<coordinates>-14.405821,-7.963539 -14.381448,-7.975707</coordinates>
</LineString>
</Placemark>
</Document>
</kml>
https://jsfiddle.net/wf9a5m75/xnw0hvvf/5/
来自 Google 的回答
我认为这是 Google Maps JS API v3 的错误,我已向 Google 报告了此问题。
但谷歌说
状态:无法修复(预期行为)
是的。我相信 Google Maps Javascript API 遵循颜色的“十六进制”1 格式。如果可能的话,我建议您调整颜色设置以遵循 Google Maps Javascript API 的十六进制格式。
https://issuetracker.google.com/issues/71991422#comment2
哇,他们真的有这个打算吗?
实际问题
失去颜色信息意味着失去折线/多边形的含义。
例如,美国国家海洋和大气管理局 (NOAA) 使用 KMZ 文件提供实时天气灾害。 https://www.weather.gov/source/crh/shapefiles/
Google 地球以正确的颜色绘制多边形(至少我认为如此),但 Google Maps API v3 的 KmlLayer 绘制所有蓝色多边形。 改变颜色意味着改变多边形的含义。 你不觉得这是个严重的问题吗?
所以,为了解决 Google Maps JS API v3 的问题,我需要知道哪一个(红色或蓝色)是正确的。 请用有效信息告诉我你的答案。
【问题讨论】:
-
这似乎违反了documentation。但我怀疑这是一个 WontFix,因为颜色规范早于 KML 规范,而且一直都是这样。
-
Google 终于承认这是一个错误(重新打开案例)。我希望他们尽快修复这个错误。 issuetracker.google.com/issues/71991422#comment7
标签: google-maps-api-3 kml google-earth