我有一个KML文件,我将其复制/粘贴在一起,形成如下所示的融合表:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.1">
<Document>
<Polygon><outerBoundaryIs><LinearRing><coordinates>-73.992177,40.743465,0.0 -74.008242,40.752352,0.0 -74.006533,40.756112,0.0 -73.983973,40.748934,0.0 -73.987733,40.744149,0.0 -73.992177,40.743465,0.0</coordinates></LinearRing></outerBoundaryIs></Polygon>
<Polygon><outerBoundaryIs><LinearRing><coordinates>-73.973035,40.689458,0.0 -73.989784,40.683305,0.0 -74.008242,40.686381,0.0 -73.978846,40.705181,0.0 -73.977479,40.698003,0.0 -73.973035,40.689458,0.0</coordinates></LinearRing></outerBoundaryIs></Polygon>
(...)
</Document>
</kml>
据我所知,在地图上绘制这些内容就像
一样简单var zipoverlay = new google.maps.KmlLayer('zips.kml');
zipoverlay.setMap(map);
但显然这没有任何作用。它不像我想象的那么神奇吗?
谢谢!
答案 0 :(得分:8)
感谢Dr.Molle,我们想出了这一点。这就是我做错了:
`
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.2">
<Document>
<Placemark>
<Polygon><outerBoundaryIs><LinearRing><coordinates>-73.992177,40.743465,0.0 -74.008242,40.752352,0.0 -74.006533,40.756112,0.0 -73.983973,40.748934,0.0 -73.987733,40.744149,0.0 -73.992177,40.743465,0.0</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark>
<Placemark><Polygon><outerBoundaryIs><LinearRing><coordinates>-73.973035,40.689458,0.0 -73.989784,40.683305,0.0 -74.008242,40.686381,0.0 -73.978846,40.705181,0.0 -73.977479,40.698003,0.0 -73.973035,40.689458,0.0</coordinates></LinearRing></outerBoundaryIs></Polygon>
</Placemark>
</Document></kml>
答案 1 :(得分:0)
<Polygon/>
必须是<Placemark/>
或<MultiGeometry/>
的孩子,而不是<Document/>
答案 2 :(得分:0)
我的错误是在我的服务器上启用了HTTP身份验证,这阻止了Google请求KML文件。我想这不是客户端。
答案 3 :(得分:0)
我遇到了此类问题(kml层未显示),因为网址(或可能只是文件名)太长。 使用较短的网址即可正常工作。