Ok, I've done it using something like this:
[code]
var pathPoints = "";
var deliveryLine = deliverDirections.getPolyline();
var pointInc = 1;
// calculate the increment - for cases where there is a large
number of points
if(deliveryLine.getVertexCount() > <?
=GOOGLE_MAPS_STATIC_MAXPOINTS;?>){
pointInc = parseInt(deliveryLine.getVertexCount() / <?
=GOOGLE_MAPS_STATIC_MAXPOINTS;?>);
}
// build a string containing the list of points
for(var i = 0; i < deliveryLine.getVertexCount(); i+=pointInc){
deliveryPoint = deliveryLine.getVertex(i);
pathPoints += ((pathPoints != "")?"|":"")
+deliveryPoint.toUrlValue();
}
// make sure the last point gets added
if(i > deliveryLine.getVertexCount()){
deliveryPoint =
deliveryLine.getVertex(deliveryLine.getVertexCount()-1);
pathPoints += ((pathPoints != "")?"|":"")
+deliveryPoint.toUrlValue();
}
[/code]
Basically that lets me have the PHP constant
GOOGLE_MAPS_STATIC_MAXPOINTS defined to the maximum number of points I
will allow for the polyline on the static map.... seems to work
nicely, and actually creates a smoother line when the map is zoomed
out far enough that there'd be too many points.
I'm still curious to hear about other possible solutions... or if
there are plans to actually include proper directions rendering into
the static maps API?
Cheers,
-Pat
On Jun 23, 10:11 am, Pat <pl...@acromediainc.com> wrote:
> Hello,
> I am working on building a page with this functionality:
> - I have 2 points on the map
> - I must show markers and directions (polyline) between these points
> - the map must be dynamic when viewed on the page
> - the map must be printable (including markers and directions)
> - the map must be able to be embedded in a PDF
> I have it working to some extent in the following way:
> - I load the dynamic map with the markers and directions
> - after the dynamic map is loaded, I generate a static version (using
> the static map API) using the same markers, and the points that were
> generated for the directions polyline
> The problem I am having is when my two points are far away, the
> directions polyline contains a large number of points which must be
> passed to the static maps API so that it prints properly and can be
> embedded in the PDF... The problem is that the list of points must be
> passed in a URL to the static maps API, and when there are a large
> number of points, the URL is too big for the static maps API to
> handle.
> So basically the problem comes down to this: is there a way to output
> the directions polyline on a static map when the points are far away?
> I am thinking one possibility would be to use a "lower resolution"
> directions polyline that only includes, say half the points... or
> won't include points that are within a certain distance of each
> other... these are options if there isn't already a "proper" way to
> embed the directions polyline on the static map.
> Has anyone dealt with this problem before? Seems like it'd be common
> enough to want to generate static maps with a polyline for directions
> drawn on...
> Thanks for any info!