admin管理员组文章数量:1291595
I have a KML file that I copy/paste together form a fusiontable which looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns=".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>
As far as I understand drawing these on the map is as easy as
var zipoverlay = new google.maps.KmlLayer('zips.kml');
zipoverlay.setMap(map);
But apparently this does nothing. Is it not as magical as I thought?
Thanks!
I have a KML file that I copy/paste together form a fusiontable which looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google./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>
As far as I understand drawing these on the map is as easy as
var zipoverlay = new google.maps.KmlLayer('zips.kml');
zipoverlay.setMap(map);
But apparently this does nothing. Is it not as magical as I thought?
Thanks!
Share Improve this question asked Apr 22, 2013 at 18:31 Paul RiedelPaul Riedel 4193 gold badges8 silver badges19 bronze badges4 Answers
Reset to default 9Thanks to Dr.Molle we figured this out. Here's what I did wrong:
- The KML file needs to be accessible from outside my own machine. Host it somewhere else in order for maps to be able to grab it
- The structure of the KML file needs to be like this:
`
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google./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>
A <Polygon/>
has to be a child of either <Placemark/>
or <MultiGeometry/>
, but not of <Document/>
My mistake was having HTTP auth enabled on my server, which was preventing google from requesting the KML file. I guess it is not done client side.
I had this kind of issue (kml layer not displaying) because the url (or maybejust the file name) was too long. With a shorter url it was working.
本文标签: javascriptGoogle Maps API V3 KML Layer not showingStack Overflow
版权声明:本文标题:javascript - Google Maps API V3: KML Layer not showing? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741537291a2384101.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论