1

I have loaded a KML file into a Google map using both V3 and geoxml3. The file contains one line, saved from Maps walking directions. I want to add mile markers to the line, but I can't find any documentation on how to get a polyline from the KmlLayer (or from the geoXML3 object).

V3:

var layer = new google.maps.KmlLayer('http://blah.kml');
layer.setMap(map);

geoXML3:

var kml_parser = new geoXML3.parser({
  map: map,
  processStyles: true,
  createMarker: add_marker
});
kml_parser.parse('blah.kml');

Does anyone know

geocodezip
  • 158,664
  • 13
  • 220
  • 245
skeniver
  • 2,647
  • 6
  • 28
  • 34

1 Answers1

1

The first Polyline is accessible in geoxml3 by:

kml_parser.docs[0].gpolylines[0]

or as a property of the placemark

kml_parser.docs[0].placemarks[0].polyline

(the Polylines are not accessible in KmlLayer, they are rendered on tiles)

Example from a search of SO for [google-maps-api-3] geoxml3 polyline)

Another example: http://www.geocodezip.com/geoxml3_test/v3_geoxml3_kmltest_linktoB.html?type=k&filename=http://www.geocodezip.com/geoxml3_test/SO_IT_info_kmlC.xml

geocodezip
  • 158,664
  • 13
  • 220
  • 245
  • Hi, I have tried both lines, but there are no docs in the parser, so I'm getting a 'cannot read property of undefined' error. kml_parser.docs.length is 0. But the KML file is loading and displaying on the map... Any clues? – skeniver Apr 04 '13 at 06:33
  • Hi, after stopping being lazy and checking the first example you posted, I managed to get the length using the afterParse option! Thank you! – skeniver Apr 04 '13 at 06:44
  • Sorry to resurrect this topic, but what is the API documentation on GeoXML3? I would like to know the available constructs and methods (just like Java API documentation, if you know what I mean). – IndoKnight Jun 22 '16 at 19:14