谷歌地图API(KML层) [英] google map api (KML layer)
问题描述
我试图用KML来划出香港岛的边界。假设在香港岛的地图上会有多边形线。
但没有显示。为什么?
任何其他方法将多边形的坐标导入Google map api?
感谢! / p>
<!DOCTYPE html>
< html>
< head>
< meta name =viewportcontent =initial-scale = 1.0>
< meta charset =utf-8>
< script src =http://maps.google.com/maps/api/js?v=3&sensor=falsetype =text / javascript>< / script>
< title> KML层< / title>
< style>
html,body {
height:100%;
保证金:0;
padding:0;
}
#map {
height:100%;
}
< / style>
< / head>
< body>
< body onload =initMap()>
< div id =map>< / div>
< script>
函数initMap(){
var map = new google.maps.Map(document.getElementById('map'),{
zoom:12,
center :{lat:22.264316,lng:114.187260}
});
var ctaLayer = new google.maps.KmlLayer({
url:'http://o3xmaps.com/gis-map-projects/201510/hkisland.kml',
map:map
});
}
< / script>
< / body>
< / html>
您的KML返回一个 对不起 第10行第27列:无效颜色:0FFFFFF(11次出现)[帮助]
< PolyStyle>< color> 0FFFFFF< / c的olor>< / PolyStyle>
第2267行第29列:XML解析错误::2267:29:格式不正确(无效标记)[帮助]
< ;名称> A06坚摩坚尼地城& Mount Davis< / name>
I tried to draw boundaries of HK island by using KML.
Supposed, there would be polygon lines on the map of the Hong Kong island.
But nothing shown. Why?
Any other methods to import data with coordinates of polygon to google map api?
THANKS !
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8">
<script src="http://maps.google.com/maps/api/js?v=3&sensor=false" type="text/javascript"></script>
<title>KML Layers</title>
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#map {
height: 100%;
}
</style>
</head>
<body>
<body onload="initMap()">
<div id="map"></div>
<script>
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 12,
center: {lat: 22.264316, lng: 114.187260}
});
var ctaLayer = new google.maps.KmlLayer({
url: 'http://o3xmaps.com/gis-map-projects/201510/hkisland.kml',
map: map
});
}
</script>
</body>
</html>
Your KML returns a KmlStatus of Kml Status:INVALID_DOCUMENT:
Sorry
This feed does not validate.
line 10, column 27: Not a valid color: 0FFFFFF (11 occurrences) [help]
<PolyStyle><color>0FFFFFF</color></PolyStyle>
^
line 2267, column 29: XML parsing error: :2267:29: not well-formed (invalid token) [help]
<name>A06 堅摩 Kennedy Town & Mount Davis</name>
If I make it valid: http://feedvalidator.org/check.cgi?url=http%3A%2F%2Fwww.geocodezip.com%2Fgeoxml3_test%2Fkml%2Fhkisland.kml
这篇关于谷歌地图API(KML层)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!