Google Maps API Tutorial© 2006, 2007, 2008, 2009 Mike Williams |
Translate this page: |
Polylines from XMLHere's an example showing how to read polyline data from an XML file.Here's the XML file. The method is similar to the processing of markers from an XML file, except now each line contains several points. When the data is processed we need to use a nested loop. The outer loop steps through the lines. The inner loop steps through the points for that line. I've put "colour" and "width" attributes in the line entries in the XML file, and used them to control the colour and width of the polylines. It's possible to have marker and polyline information in the same XML file. The 'getElementsByTagName("marker")' bit only reads the markers and the 'getElementsByTagName("line")' bit only reads the lines. Potential Pitfalls
|