1

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?

Azat
  • 6,745
  • 5
  • 31
  • 48
Marco94
  • 17
  • 7

1 Answers1

2

The google.maps.Polygon objects created by geoXml3 to represent the KML polygons can be accessed 2 ways:

  1. area[controlli[0].id].docs[0].placemarks[0].polygon.getPath()

working jsfiddle

  1. area[controlli[0].id].docs[0].gpolygons[0].getPath()

working jsfiddle

where geoXml is a reference to the parser object (your area[controlli[i].id]) and i is a sequential reference to the placemarks (or the polygons) in the KML).

If you are using it on a KML file loaded asynchronously, you need to wait for the parsed event, or use the data in the afterParse function.

Marco94
  • 17
  • 7
geocodezip
  • 158,664
  • 13
  • 220
  • 245