Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
How to show driving directions on static map
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Pat  
View profile  
 More options Jun 23 2008, 1:11 pm
From: Pat <pl...@acromediainc.com>
Date: Mon, 23 Jun 2008 10:11:18 -0700 (PDT)
Local: Mon, Jun 23 2008 1:11 pm
Subject: How to show driving directions on static map
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!


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pat  
View profile  
 More options Jun 23 2008, 1:42 pm
From: Pat <pl...@acromediainc.com>
Date: Mon, 23 Jun 2008 10:42:54 -0700 (PDT)
Local: Mon, Jun 23 2008 1:42 pm
Subject: Re: How to show driving directions on static map
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:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google