向KML脚本添加图标时遇到麻烦



我在使用KML和google地图时遇到了一些麻烦。我想从图标标签链接到显示自定义图标。下面是代码:

<?xml version="1.0" encoding="utf-8"?>
<kml xmlns="http://earth.google.com/kml/2.2">
<Document>
     <Style id="CaliforniaCity">
        <IconStyle>
         <scale> 1.0</scale>
          <Icon>
            <href>http://maps.google.com/mapfiles/kml/shapes/shaded_dot.png</href>
          </Icon>
        </IconStyle>
      </Style>
      <Placemark id=test>
        <name>Test</name>
        <styleUrl>#CaliforniaStyle</styleUrl>
        <Point>
          <coordinates>
            -121.0,38.0,0
          </coordinates>
        </Point>
      </Placemark>
      <Placemark id=test1>
        <name>Test1</name>
        <styleUrl>#CaliforniaStyle</styleUrl>
        <Point>
          <coordinates>
            -121.05,38.10,0
          </coordinates>
        </Point>
      </Placemark>
      <Placemark id=test2>
        <name>Test2</name>
        <styleUrl>#CaliforniaStyle</styleUrl>
        <Point>
          <coordinates>
            -121.10,38.5,0
          </coordinates>
        </Point>
       </Placemark>
</Document>
</kml>

我不确定我哪里出错了,因为类似的代码在书中工作。

谢谢

你打错字了

<Style id="CaliforniaCity">
<styleUrl>#CaliforniaStyle</styleUrl>

您的xml也是无效的。

工作示例

最新更新