我可以在谷歌地球上显示KML。现在我想在地图上显示相同的内容。这怎么可能呢?这是我的KML附件。
<?xml version="1.0" encoding="UTF-8"?> <kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<name>Hide and show labels</name>
<Style id="sn_hide">
<IconStyle>
<scale>0</scale>
</IconStyle>
</Style>
<StyleMap id="msn_hide">
<Pair>
<key>normal</key>
<styleUrl>#sn_hide</styleUrl>
</Pair>
</StyleMap>
<Placemark>
<name>Placemark 1</name>
<description>Label hidding</description>
<styleUrl>#sn_hide</styleUrl>
<Point>
<coordinates>-119.232195,36.016021</coordinates>
</Point>
</Placemark>
<Placemark>
<name>Placemark 2</name>
<description>Label hidding</description>
<styleUrl>#sn_hide</styleUrl>
<Point>
<coordinates>-119.232195,36.0162</coordinates>
</Point>
</Placemark>
</Document>
</kml>
提前谢谢..
发布于 2012-11-15 13:57:36
要在Google Map上显示KML,它需要位于可公开访问的web服务器上。
然后使用Google Maps API v3 KmlLayer或Google Maps
Google Maps API v3 KmlLayer example from the documentation
显示KML文件的代码:
var chicago = new google.maps.LatLng(41.875696,-87.624207);
var mapOptions = {
zoom: 11,
center: chicago,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
var ctaLayer = new google.maps.KmlLayer('http://gmaps-samples.googlecode.com/svn/trunk/ggeoxml/cta.kml');
ctaLayer.setMap(map);
Here与Google Maps上显示的KML文件相同。
更新:
Here">http://www.geocodezip.com/geoxml3_test/Point_Placemarks.Descriptive_HTML_kml.xml">Here是使用Google Maps API v3 geoxml3第三方解析器显示的评论中的文件的本地副本(KmlLayer似乎认为它是一个无效文档)
https://stackoverflow.com/questions/13391825
复制相似问题