KML应绘制红色折线还是蓝色折线?

时间:2018-01-16 18:55:26

标签: google-maps-api-3 kml google-earth

请告诉我哪一个是“KML文件格式的正确行为”。

如您所知,< color> KML的标签包含订单 AABBGGRR 的颜色信息。这在OGC KML文档中定义。

  

16.9 kml:colorType

     

表达式的顺序是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/ enter image description here

例2:

但是,使用此KML文件时,Google Maps API会绘制蓝色行,但Google地球仍会绘制红色折线。

<?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/

enter image description here

Google的答案

我认为这是Google Maps JS API v3的一个错误,我向Google报告了这个错误。

但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会绘制所有蓝色多边形。 更改颜色意味着更改多边形的含义。 你不觉得这是严重的问题吗?

enter image description here

因此,为了要求解决Google Maps JS API v3的问题,我需要知道哪一个(红色或蓝色)是正确的。 请用有效的信息告诉我你的答案。

1 个答案:

答案 0 :(得分:0)

有关KML的正式解释,请直接参考Open Geospatial Consortium (OGC) KML 2.2 standard。注意KML 2.3已发布,但尚未在Google Earth或Google Maps中实现。关于visibility tag存在一个问题,其中Google Earth实现的行为与KML规范相反,但是修复会破坏现有代码,因此不会被“修复”。 在出现矛盾的情况下,官方OGC KML标准将取代任何供应商文档或实施方式

KML 2.2(文档编号07-147r2)在第16.8.1节中规定以下内容:

  

表达顺序为 aabbggrr ,其中aa = alpha(00至ff);   bb = blue(00至ff); gg =绿色(00至ff); rr =红色(00至ff)

在16.7.1中还给出了一个示例,其中 ff0000ff 的值表示红色,最后2个字符(ff)表示红色。

这表示Google地球正在使用<color>7f0000ff</color>红色来正确显示KML呈现功能。 Google Maps API无法正确呈现它,并且是一个错误。

参考: