好吧,我已经通读了一遍,并试图找到解决方案,但失败了…
我遵循了geoxmlv3中的说明:http://code.google.com/p/geoxml3/wiki/Usage
以下是该文档中引用:
<script type="text/javascript">
var myParser = new geoXML3.parser({afterParse: useTheData});
myParser.parse('my_geodata.kml');
function useTheData(doc) {
// Geodata handling goes here, using JSON properties of the doc object
for (var i = 0; i < doc.placemarks.length; i++) {
doSomething;
}
};
</script>根据文档,doc.placemarks应该正常工作,并在KML文件中返回一个placemarks的json数组,不幸的是,这个'doc‘甚至不存在(未定义),你知道吗?
发布于 2012-12-26 20:49:53
如果你使用的是聚分支,"doc“就是一个数组。
function useTheData(doc) {
// Geodata handling goes here, using JSON properties of the doc object
for (var i = 0; i < doc[0].placemarks.length; i++) {
doSomething;
}
};我将修复文档中的示例。
working example
发布于 2012-12-26 12:03:36
为什么不使用Google Maps API v3的KmlLayer?很容易将信息从KML文件映射到地图上。
https://developers.google.com/maps/documentation/javascript/layers#KMLLayers
https://stackoverflow.com/questions/14035816
复制相似问题