【发布时间】:2011-08-09 18:03:41
【问题描述】:
我希望为地标设置两个名称,一个在地标悬停时显示,一个在未悬停时显示。我能找到的唯一信息是更改突出显示的地标样式的样式(图标类型、颜色、不透明度、比例)。有什么建议么?这可能吗?
http://code.google.com/apis/kml/documentation/kml_tut.html#custom_styles
【问题讨论】:
标签: kml google-earth
我希望为地标设置两个名称,一个在地标悬停时显示,一个在未悬停时显示。我能找到的唯一信息是更改突出显示的地标样式的样式(图标类型、颜色、不透明度、比例)。有什么建议么?这可能吗?
http://code.google.com/apis/kml/documentation/kml_tut.html#custom_styles
【问题讨论】:
标签: kml google-earth
您可以使用自定义图标以相同的方式显示一个伪名称(您需要的文本图像)和另一个翻转伪名称。
这称为“突出显示图标的样式”,要使用它,您需要创建并上传两个 jpg 图像
nameImageOver.jpg
和
nameImageNormal.jpg
kml 看起来像这样:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<name>Highlighted Icon</name>
<description>Mouse over to see the swap</description>
<Style id="highlightPlacemark">
<IconStyle>
<Icon>
<href>http://www.yourserver.com/nameImageOver.jpg</href>
</Icon>
</IconStyle>
</Style>
<Style id="normalPlacemark">
<IconStyle>
<Icon>
<href>http://www.yourserver.com/nameImageNormal.jpg</href>
</Icon>
</IconStyle>
</Style>
<StyleMap id="exampleStyleMap">
<Pair>
<key>normal</key>
<styleUrl>#normalPlacemark</styleUrl>
</Pair>
<Pair>
<key>highlight</key>
<styleUrl>#highlightPlacemark</styleUrl>
</Pair>
</StyleMap>
<Placemark>
<styleUrl>#exampleStyleMap</styleUrl>
<Point>
<coordinates>-122.0856545755255,37.42243077405461,0</coordinates>
</Point>
</Placemark>
</Document>
</kml>
【讨论】:
我使用 Google Earth API 实现了这一点。不确定这与使用 KML 有什么关系...
// On mouse over - show name
google.earth.addEventListener(placemark, 'mouseover', function(event) {
placemark.setName('My Placemark Label');
});
// On mouse out - hide (remove) name
google.earth.addEventListener(placemark, 'mouseout', function(event) {
placemark.setName('');
});
【讨论】: