【发布时间】:2015-02-19 05:59:30
【问题描述】:
我认为这是我“只见树木不见森林”的错误之一。我已经为此工作了几天,但我似乎无法确定问题所在。它不应该那么难;但我认为我离代码太近了(或者对 .kml 太不熟悉了)看不到它。
我有这个 .kml 文件,我在下面发布了它。我已经消除了大部分,所以它只显示一个有问题的地址。 (该文件最初有十几个或更多带有颜色的正方形的“IconStyle”标签。)
我的 .kml 文件将在 Google 地球中提取沃尔玛的地址。我想显示的图标位于此 URL(来自文件): http://maps.google.com/mapfiles/kml/pal4/icon18.png(是一个绿色圆圈内的正方形。)
但是,当我运行下面的代码时,显示的是一个红色方块!细心的眼睛将不胜感激!谢谢!
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.1/">
<Document>
<name>test.kml</name>
<description>testIcon</description>
<LookAt>
<longitude>-111.5863733742289</longitude>
<latitude>39.55637809106051</latitude>
<altitude>0</altitude>
<range>610178.2115040587</range>
<tilt>-1.037184070538429e-013</tilt>
<heading>0.5510762374861048</heading>
</LookAt>
<StyleMap id="te">
<Pair>
<key>normal</key>
<styleUrl>#te1</styleUrl>
</Pair>
<Pair>
<key>highlight</key>
<styleUrl>#te2</styleUrl>
</Pair>
</StyleMap>
<StyleMap id="fac">
<Pair>
<key>normal</key>
<styleUrl>#fac1</styleUrl>
</Pair>
<Pair>
<key>highlight</key>
<styleUrl>#fac2</styleUrl>
</Pair>
</StyleMap>
<Style id="te1">
<IconStyle>
<color>ff87ff66</color>
<scale>0.8</scale>
<Icon>
<href>http://maps.google.com/mapfiles/kml/pal4/icon56.png</href>
</Icon>
</IconStyle>
<LabelStyle>
<scale>0</scale>
</LabelStyle>
</Style>
<Style id="te2">
<IconStyle>
<color>8887ff66</color>
<scale>1.2</scale>
<Icon>
<href>http://maps.google.com/mapfiles/kml/pal4/icon56.png</href>
</Icon>
</IconStyle>
</Style>
<Style id="fac1">
<IconStyle>
<scale>1.0</scale>
<Icon>
<href>http://maps.google.com/mapfiles/kml/pal4/icon18.png</href>
</Icon>
</IconStyle>
<LabelStyle>
<scale>0</scale>
</LabelStyle>
</Style>
<Style id="fac2">
<IconStyle>
<color>66ffffff</color>
<scale>1.3</scale>
<Icon>
<href>http://maps.google.com/mapfiles/kml/pal4/icon18.png</href>
</Icon>
</IconStyle>
</Style>
<Placemark>
<name>Walmart</name>
<address>1710 E Skyline Dr, South Ogden, UT 84405</address>
<styleUrl>#te</styleUrl>
<description><![CDATA[<div>Some Text</div>]]></description>
<styleUrl>#fac</styleUrl>
</Placemark>
</Document>
</kml>
【问题讨论】:
-
请注意,地标中有两个 styleUrl 元素,这对于 KML 无效(每个地标只允许一个 styleUrl 元素) -- developers.google.com/kml/documentation/kmlreference#placemark
标签: google-maps-api-3 kml