我正在寻找两个地名的名字,一个是地标悬停时显示的名字,另一个是没有悬停的地名。我所能找到的唯一信息是改变高亮地标风格的风格(图标类型,颜色,不透明度,比例)。有什么建议么?这可能吗?动态KML地标名称显示可能吗?
http://code.google.com/apis/kml/documentation/kml_tut.html#custom_styles
我正在寻找两个地名的名字,一个是地标悬停时显示的名字,另一个是没有悬停的地名。我所能找到的唯一信息是改变高亮地标风格的风格(图标类型,颜色,不透明度,比例)。有什么建议么?这可能吗?动态KML地标名称显示可能吗?
http://code.google.com/apis/kml/documentation/kml_tut.html#custom_styles
你可以使用自定义图标呈现伪名(您所需要的文本的图像),并以同样的方式另一卷在伪名。
这就是所谓的“风格为高亮显示的图标”,使用它,你需要创建并上传两个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('');
});
在我的情况下,文本是动态的不同的地标。您的解决方案适用于静态标题,或者您想为每个可能的组合创建一个图像。我会将其标记为正确,因为在某些情况下它是可行的。 –
你可以使用像gdlib这样的东西在服务器上动态生成图像。谷歌甚至有免费的服务来做到这一点。只需提供您需要的文本作为查询。请参阅http://groups.google.com/group/google-chart-api/web/chart-type-for-text-with-outline?pli=1 – Fraser