I am working on a printable version of a route and have a routine that
builds a Static Map.  It "works", but has a problem when there are too
many vertices in the Polyline.  The URL becomes to large for the
Static Map API.

My code for gp_compressShapes() works to encode the line fine.

My code is below.

// dirn is the GDirections object
var poly = dirn.getPolyline();
var vertCount = poly.getVertexCount();
var llArray = new Array();
for (var i=0; i < vertCount; i++) {
        llArray.push(poly.getVertex(i).lat());
        llArray.push(poly.getVertex(i).lng());
}
var encPoly = gp_compressShapes(llArray,5);
staticMapURL += '&path=enc:' + encPoly;

*** My main question is whether there is a good way to use a subset of
the vertices in the Polyline to still give it the effect of the route
path, but not all the detail.

An encoded LatLng seems to be about 10 characters on average.  Since
URLs cannot be too long, I am thinking I'd work with an arbitrary
number of the Vertices (e.g. 200) and take every nth one so I have <=
200 total and then encode that.  Worst case is that this gives me a
less detailed polyline, but it on the same path.

Thoughts?

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps API V2" 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