In case it helps anyone, here's a little "gotcha" related to creating
polylines that may be obvious to others but was not to me.

We used Google Earth to create some polylines. We saved those into a
KML file and then we read the coordinates of the KML file in via
script and stored the polyline data in a JavaScript array, then tried
to display the polylines on a map in a browser.

After loading the data from the KML file we used the JavaScript split
function to break each list of coordinates into a new array and then
invoked GLatLng on them to make an array of points acceptable to
GPolyline.

All this was straightforward and should not have caused any problems,
so it took a while to figure out why the polylines would not appear on
the map as expected. We looked at the first few data coordinates for
each polyline and all appeared well with them.

The problem was that the JavaScript split function was creating an
"undefined" element as the last item in each array, every time.
Somewhere along the line between saving the file and extracting its
data the set of coordinates ended up with an extra blank item at the
end. Once we ensured no "undefined" elements were present for creating
new GLatLng points everything instantly worked.

When this array of LatLng points was being fed into GPolyline, there
was no indication of the problem. There was no JavaScript or other
error message anywhere coming back from the API, we just had no
polyline.

If some kind of error could be returned by GPolyline when it does not
like its array of points, that would be useful. In this kind of case
it seems that GPolyline ought to draw all the valid segments it does
receive, but fail and return an error when it finds an invalid point.
(Perhaps the GLatLng function could return an error too if it receives
invalid data, which would have caught this before it went to the
GPolyline.)

-Ken

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to