在Google Earth消费的KML文件中,我使用的是Google Charts动态图标,其URL包含百分比编码字符,例如this one。通过截取网络调用可以看出,%E2%80%A2 (项目符号字符)被Google Earth损坏为%C3%A2%C2%80%C2%A2,这会导致图标检索失败。问题是KML规范非常模糊:对于HTTP href元素,它只会说它是“一个IconStyle地址……用于加载图标”。那么,有没有谷歌人能解释清楚Google Earth期望的是什么,以及如何使KML文件中带有百分比编码字符的图标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>
发布于 2013-06-02 14:28:58
经过很长一段时间的平静后,我又回到了这个问题上,并找到了答案。即使您插入的是URL,因此应该应用URL编码准则,但KML希望特殊实体是Unicode编码的,而不是URL编码的,即使在URL中也是如此!换句话说,你需要这样:
<href>http://chart.apis.google.com/chart?chst=d_map_pin_letter_withshadow&chld=•|cccccc|000000</href>
回想起来,它需要“”为与符号,这应该让我在正确的轨道上,但事后总是20/20…
https://stackoverflow.com/questions/10582547
复制相似问题