我一直试图通过以下方式在Google地图中呈现我的KML服务。
var ctaLayer = new google.maps.KmlLayer({
url: 'http://DomainName/GeoSystem/redrawKML'
});
ctaLayer.setMap(map);
但是当我检查状态时,我正在使用 ctaLayer对象获得undefined
。
但是同样的服务运行良好,如果我试图用geoXML解析器解析KML服务。现在,我很困惑,不知道。为什么我无法使用谷歌地图中的谷歌地图KML图层渲染我的KML服务。
非常感谢任何帮助。
我的Woring代码包含GeoXML库。
var geoXml = new geoXML3.parser({
map : map,
singleInfoWindow : true
});
geoXml.parse('http://DomainName/GeoSystem/redrawKML');
以下是我的KML内容,该内容将由我的休息服务(http://DomainName/GeoSystem/redrawKML
)
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:ns2="http://www.google.com/kml/ext/2.2" xmlns:ns3="http://www.w3.org/2005/Atom" xmlns:ns4="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0">
<Document>
<name>My KML Document</name>
<Placemark>
<name>Fort Worth</name>
<open>1</open>
<description>Fort Worth , Dallas</description>
<ExtendedData>
<Data name="GeoRegionId">
<value>1</value>
</Data>
<Data name="PolygonId">
<value>132</value>
</Data>
</ExtendedData>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>-97.47551,32.778615 -97.45079,32.79651 -97.437744,32.798242 -97.420578,32.806322 -97.417145,32.813824 -97.34848,32.843251 -97.338867,32.842674 -97.317581,32.838635 -97.292862,32.838058 -97.264709,32.839212 -97.229691,32.840943 -97.207718,32.831135 -97.206345,32.814978 -97.211838,32.802859 -97.212524,32.758985 -97.224884,32.739927 -97.225571,32.716822 -97.240677,32.691977 -97.239304,32.667125 -97.245483,32.661922 -97.281876,32.6625 -97.304535,32.668859 -97.334061,32.663656 -97.380066,32.671749 -97.402725,32.684464 -97.459717,32.683308 -97.47139,32.695444 -97.478943,32.720288 -97.482376,32.741082 -97.47551,32.778615
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
</Document>
</kml>
答案 0 :(得分:1)
您检查了KML limits of Google Maps API v3吗?如果超过功能数量或文件重量限制,则不会显示任何内容。
修改强>: 我将您的kml上传到我的公共Dropbox文件夹。
我装的很好var fortw = new google.maps.KmlLayer({
url: 'https://dl.dropboxusercontent.com/u/3133731/fortworth.kml',
map: map
});
答案 1 :(得分:1)
得到了答案。
如果谷歌地图API3的KMLLayer必须显示内容,KML File should be in PUBLICALLY ACCESIBLE
。然后,只有谷歌服务器可以解析该文件,并将其在谷歌地图中呈现。
因为我在当地环境中发展。 Google Server can not parse the KML File which i am providing. That is why the contents are not rendered in the Google maps.