2015-10-10 235 views
0

我試圖用KML來繪製香港島的邊界。谷歌地圖API(KML層)

假設在香港島的地圖上會出現多邊形線條。

但沒有顯示。爲什麼?

任何其他方法導入數據與多邊形的座標到谷歌地圖API?

謝謝!

<!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> 

回答

0

您的KML返回KML狀態的KmlStatus:INVALID_DOCUMENT:

http://www.geocodezip.com/v3_GoogleEx_layer-kml_linktoB.html?filename=http://o3xmaps.com/gis-map-projects/201510/hkisland.kml

Your KML is not valid.

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> 

如果我讓它有效: http://feedvalidator.org/check.cgi?url=http%3A%2F%2Fwww.geocodezip.com%2Fgeoxml3_test%2Fkml%2Fhkisland.kml

It works for me