Directions API Step polyline problem

296 views
Skip to first unread message

ccrum

unread,
May 23, 2012, 1:49:01 AM5/23/12
to Google Maps JavaScript API v3
I recently noticed that the polyline returned in each step in a route
does not always start and end with the coordinates the step says it
does. For Instance, I ran a directions query from Fort Worth, TX to
Austin, TX. The start and end points returned were:

32.72468 -97.32085 and 32.04823 -97.09488
and it's html was "Take the ramp on the <b>left</b> onto <b>I-35W S</
b>"

The start point of the polyline was indeed 32.72468 -97.32085 but the
last point of the polyline was 32.48797,-97.54039. The polyline also
contained 603 points. This is a dramatic difference in location
between what the path reports and the polyline shows. Furthermore,
Step 3 started with the declared end point of Step 2 (32.04823
-97.09488) and continued on. There were breaks like this in other
steps as well. Step 3 had the following start and end coordinates
listed in the step:

32.04823 -97.09488 and 31.04757 -97.46572

and once again the Step 3 polyline started with the same coordinates
(32.04823 -97.09488), but ended dramatically different with
31.21956,-97.61789 as the last point of the polyline. Step 4 was also
off, but steps 5,6,7, and 8 had matching step coordinates and polyline
start and end coordinates. The latter steps were also much shorter
containing only a few sets of coordinates whil3 2,3 and 4 had several
hundred coordinates each.

So, does anyone have any idea why this is happening? If I try to plot
the lines on a map abased on the polyline coordinates, I get several
disjointed lines and they are definitely not the route from Fort Worth
to Austin unless Google is assuming we can teleport along the path. I
need the actual polylines as I am trying to determine total miles
traveled per state and can do an intersect query in SQL spatial
against a set of state polygons to determine which step subsections
are in which states. If the polylines "wander" like this, I won't be
able to use them.

Regards,

Cameron

geoco...@gmail.com

unread,
May 23, 2012, 9:20:00 AM5/23/12
to Google Maps JavaScript API v3
On May 22, 10:49 pm, ccrum <cameron.c...@gmail.com> wrote:
> I recently noticed that the polyline returned in each step in a route
> does not always start and end with the coordinates the step says it
> does. For Instance, I ran a directions query from Fort Worth, TX to
> Austin, TX. The start and end points returned were:
>
> 32.72468 -97.32085 and 32.04823 -97.09488
> and it's html was "Take the ramp on the <b>left</b> onto <b>I-35W S</
> b>"

A link to a map would be better.

I get this:
http://www.geocodezip.com/v3_GoogleEx_directions-draggable2Xml.html?addr1=Fort%20Worth,%20TX&addr2=Austin,%20TX

The first point of the polyline returned for me is:
<point lat='32.725410' lng='-97.320840' />

>
> The start point of the polyline was indeed 32.72468 -97.32085 but the
> last point of the polyline was 32.48797,-97.54039.

The last point of the polyline I get is:
<point lat='30.267100' lng='-97.743080' />

> The polyline also
> contained 603 points. This is a dramatic difference in location
> between what the path reports and the polyline shows. Furthermore,
> Step 3 started with the declared end point of Step 2 (32.04823
> -97.09488) and continued on. There were breaks like this in other
> steps as well. Step 3 had the following start and end coordinates
> listed in the step:
>
> 32.04823 -97.09488 and  31.04757 -97.46572
>
> and once again the Step 3 polyline started with the same coordinates
> (32.04823 -97.09488), but ended dramatically different with
> 31.21956,-97.61789 as the last point of the polyline. Step 4 was also
> off, but steps 5,6,7, and 8 had matching step coordinates and polyline
> start and end coordinates. The latter steps were also much shorter
> containing only a few sets of coordinates whil3 2,3 and 4 had several
> hundred coordinates each.
>
>  So, does anyone have any idea why this is happening? If I try to plot
> the lines on a map abased on the polyline coordinates, I get several
> disjointed lines and they are definitely not the route from Fort Worth
> to Austin unless Google is assuming we can teleport along the path. I
> need the actual polylines as I am trying to determine total miles
> traveled per state and can do an intersect query in SQL spatial
> against a set of state polygons to determine which step subsections
> are in which states. If the polylines "wander" like this, I won't be
> able to use them.

What polyline are you looking at? The simplified summary polyline
(overview_path) or the polylines in the steps (path)?

-- Larry

>
> Regards,
>
> Cameron

Cameron Crum

unread,
May 23, 2012, 9:40:33 AM5/23/12
to google-map...@googlegroups.com
Steps.


--
You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group.
To post to this group, send email to google-map...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.


geoco...@gmail.com

unread,
May 23, 2012, 10:06:43 AM5/23/12
to Google Maps JavaScript API v3
On May 23, 6:40 am, Cameron Crum <cameron.c...@gmail.com> wrote:
> Steps.

Does your map get different results from mine?

>
> On Wed, May 23, 2012 at 8:20 AM, geocode...@gmail.com
> <geocode...@gmail.com>wrote:
>
>
>
>
>
>
>
> > On May 22, 10:49 pm, ccrum <cameron.c...@gmail.com> wrote:
> > > I recently noticed that the polyline returned in each step in a route
> > > does not always start and end with the coordinates the step says it
> > > does. For Instance, I ran a directions query from Fort Worth, TX to
> > > Austin, TX. The start and end points returned were:
>
> > > 32.72468 -97.32085 and 32.04823 -97.09488
> > > and it's html was "Take the ramp on the <b>left</b> onto <b>I-35W S</
> > > b>"
>
> > A link to a map would be better.
>
> > I get this:
>
> >http://www.geocodezip.com/v3_GoogleEx_directions-draggable2Xml.html?a...

Cameron Crum

unread,
May 23, 2012, 12:18:53 PM5/23/12
to google-map...@googlegroups.com
Since I am doing this all server side with no need to draw a map, I'm using perl and some modules obtained from CPAN. Specifically, I'm using Google::Directions. It turns out that the module had an error in the Polyline.pm module. For some reason it was decoding the polyline as a series of offsets from the last point instead of just decoding the values as the lat and lons. I modified the module so it now decodes the lat/lon pairs correctly and all is well. Thanks.

Cameron

Andrew Leach

unread,
May 23, 2012, 4:59:30 PM5/23/12
to google-map...@googlegroups.com
On 23 May 2012 17:18, Cameron Crum <camero...@gmail.com> wrote:
> Since I am doing this all server side with no need to draw a map, I'm using
> perl and some modules obtained from CPAN.

Um... you do need to draw a map.

Terms of Service 10.1.1(g). "You must not use or display the Content
without a corresponding Google map, unless you are explicitly
permitted to do so in the Maps APIs Documentation, or through written
permission from Google. In any event, you must not use or display the
Content on or in conjunction with a non-Google map."

Server-side Directions API documentation says "Note: the Directions
API may only be used in conjunction with displaying results on a
Google map; using Directions data without displaying a map for which
directions data was requested is prohibited. Additionally, calculation
of directions generates copyrights and warnings which must be
displayed to the user in some fashion."

Cameron Crum

unread,
May 23, 2012, 5:05:52 PM5/23/12
to google-map...@googlegroups.com
Let me clarify...I don't need the map to do the analysis, but there will be a map at the end with the enhanced data listed.

Cameron

Reply all
Reply to author
Forward
0 new messages