【发布时间】:2012-05-21 21:23:18
【问题描述】:
在用于 Google 地球的 KML 文件中,我使用了 Google Charts 动态图标,其 URL 包含百分比编码字符,例如 this one。截取网络调用可以看出,%E2%80%A2(子弹字符)被谷歌地球修改为%C3%A2%C2%80%C2%A2,导致图标检索失败。问题是 KML 规范非常模糊:对于 IconStyle Icon href 元素,它只会说它是“用于加载图标的 HTTP 地址 [...]”。那么,任何 Google 员工能否阐明 Google 地球的期望以及如何使 KML 文件中带有百分比编码字符的图标 URL 正常工作?
请不要因为上面的 URL 有什么不正确而让我感到悲伤:它在浏览器中运行良好(在将  替换为 & 号之后)并且在 dynamic icons developer reference 的中途有一个类似的示例.
一个实际的 KML 示例文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Folder>
<Placemark>
<Style>
<IconStyle>
<scale>1.6</scale>
<Icon>
<!-- doesn't work -->
<href>http://chart.apis.google.com/chart?chst=d_map_pin_letter_withshadow&chld=%E2%80%A2|cccccc|000000</href>
</Icon>
</IconStyle>
</Style>
<Point>
<coordinates>-3.67,40.51</coordinates>
</Point>
</Placemark>
<Placemark>
<Style>
<IconStyle>
<scale>1.6</scale>
<Icon>
<!-- works -->
<href>http://chart.apis.google.com/chart?chst=d_map_pin_letter_withshadow&chld=O|cccccc|000000</href>
</Icon>
</IconStyle>
</Style>
<Point>
<coordinates>-3.68,40.52</coordinates>
</Point>
</Placemark>
</Folder>
</Document>
</kml>
【问题讨论】:
-
这很奇怪。请注意,这不是编码,因为您可以对其他参数进行编码(例如 cccccc => %63...)。似乎图表 api 不想返回一些特定的字符......,但另一方面,在 Firefox 中访问这些相同的东西时,它工作正常(返回正确的图像)。好奇怪。
-
(虽然我确实确认在wireshark中看到了更改的编码......)。我想你是对的;某处编码被破坏(在某些基础上对我来说不是很明显)。我认为这是一个错误。
标签: url kml google-earth