如何在kml文件中添加自定义标记?

时间:2016-01-13 23:18:13

标签: kml marker

如何在KML文件中添加自定义标记?为什么我的代码不起作用?

新修改的代码:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Style id="mycustommarker">
<IconStyle>
<Icon>
<href>http://www.exemple.com/image.png</href>
</Icon>
</IconStyle>
</Style>
<Placemark>
<name>Name</name>
<description>Description</description>
<Point>
<coordinates>-8.291014,47.813155,0</coordinates>
</Point>
</Placemark>
</kml>

1 个答案:

答案 0 :(得分:0)

IconStyle的href属性必须是相对文件或绝对URL。示例中的值“exemple.com/img.png”不是完全限定的URL。

示例:

 <Style id="randomColorIcon">
      <IconStyle>        
         <Icon>
            <href>http://maps.google.com/mapfiles/kml/shapes/airports.png</href>
         </Icon>
      </IconStyle>
   </Style>

这是一个尝试的工作示例 http://kml-samples.googlecode.com/svn/trunk/kml/Style/yellow-paddle.kml

更多细节可以在KML参考文档中找到:
https://developers.google.com/kml/documentation/kmlreference#iconstyle

此外,如有疑问,请使用KML validator检查您的KML。您会注意到3个错误,包括使用非标准命名空间 - 应该使用xmlns =“http://www.opengis.net/kml/2.2”而不是“http://earth.google.com/kml/2.2”。