I had more than 600 kml
files to load in a single google map.
Initially I tried with KmlLayer()
, but it didn't work due to the amount of kml
files, so I found GeoXML3
, and it works really fine.
Now I need to retrieve the path's coords for every polygon created with GeoXML3. Here I found the method getPaths()
that seems to be just what I'm looking for, but it doesn't work because now I don't create polygons using the class Polygon
but using the class geoxml3
for (i=0; i < controlli.length; i++)
{
appo = kmlurl + controlli[i].id + ".kml";
appo = appo.replace(" ", '_');
area[controlli[i].id] = new geoXML3.parser({
map: map,
zoom: false,
});
area[controlli[i].id].parse(appo);
//here I would like to do something like: 'area[controlli[i].id].getPaths()'
}
How can I do this?
答案 0 :(得分:1)
geoXml3创建的用于表示KML多边形的google.maps.Polygon对象可以通过两种方式访问:
area[controlli[0].id].docs[0].placemarks[0].polygon.getPath()
area[controlli[0].id].docs[0].gpolygons[0].getPath()
其中geoXml是对解析器对象的引用(您的area[controlli[i].id]
)
我是KML中地标(或多边形)的顺序参考。
如果您在异步加载的KML文件上使用它,则需要等待parsed
事件,或使用afterParse
函数中的数据。