KML 验证器不接受 IconStyle 定义

IconStyle defintion not accepted by KML validator

我有一个 KML 文件,它曾在 Google 地图和 Google 地球中正确显示。现在 Google 地图拒绝该文件,而地球仍然接受它并显示内容。这是文件:

http://www.skiforeningen.no/marka/kml/milorg.kml

http://www.kmlvalidator.com/ 的 Galdos 验证器在第 19 行指出以下错误:

cvc-complex-type.2.4.a: Invalid content was found starting with element 'IconStyle'. One of '{"http://www.opengis.net/kml/2.2":PolyStyle, "http://www.opengis.net/kml/2.2":BalloonStyle, "http://www.opengis.net/kml/2.2":ListStyle, "http://www.opengis.net/kml/2.2":StyleSimpleExtensionGroup, "http://www.opengis.net/kml/2.2":StyleObjectExtensionGroup}' is expected.

但是在

阅读文档时

https://developers.google.com/kml/documentation/kmlreference#style

我不明白为什么不允许她使用 IconStyle?此外,http://feedvalidator.org/ 处的验证器验证文件没有错误,并表明它是有效的 KML 2.2 提要。

非常感谢任何帮助,谢谢。

http://feedvalidator.org/ 表示您的 KML 有效。

KML content isn't available in Google Maps 了。

来自上面的link:

While using Google Maps, you might have received a notification saying "Some custom on-map content could not be displayed."

That’s because a certain type of content isn’t available anymore in the classic version of Google Maps or in maps embedded on other websites from the classic version of Maps. The content type that’s no longer available is KML, the file format Google Earth uses for the exchange of geographic information.

If you're the owner of a custom map with KML content, you need to update your content. Or, you can import your KML content into My Maps.

一种解决方法: 它works with the Google Maps Javascript API v3 KmlLayer

KML 对于 KML XML 架构无效,因此验证器错误是正确的。 KML 中元素的顺序是严格的。 Google地球在大多数情况下会忽略元素的顺序。

您的 KML 的样式结构如下:

  <Style id="MILORG1">
    <LineStyle>
    ...
    </LineStyle>

    <IconStyle>
    ...
    </IconStyle>

    <BalloonStyle>
    </BalloonStyle>
  </Style>

但Style元素中正确的元素排列顺序如下:

  <IconStyle>...</IconStyle>
  <LabelStyle>...</LabelStyle>
  <LineStyle>...</LineStyle>
  <PolyStyle>...</PolyStyle>
  <BalloonStyle>...</BalloonStyle>
  <ListStyle>...</ListStyle>

只需重新排列您的元素以符合 KML 规范。 IconStyle 必须出现在列表中的 LineStyle 之前。