How to route via many waypoints?

4,138 views
Skip to first unread message

Mario

unread,
Jul 23, 2010, 3:57:37 PM7/23/10
to Google Maps JavaScript API v3
Hi all,

I want to build an application where GPS data is tracked using an
Adroid phone, stored on a database and a route following all these
coordinates is later displayed on the web. Now, I have seen the
limitation of the DirectionsService causing a MAX_WAYPOINTS_EXCEEDED
status error, so this won't work with a sufficient number of
waypoints. Using polylines doesn't appear a valid option neither since
it will not follow roads but rather create straight lines between
neighboring waypoints.

So, what would be the right way of doing it? Can KML be of any help
here? Or just send over pairs of neighboring waypoints to the
DirectionsService, get the routing between these -- and append all the
various routes as legs server-side on my own?

Any hint most welcome.

Thanks.

geoco...@gmail.com

unread,
Jul 24, 2010, 10:48:59 AM7/24/10
to Google Maps JavaScript API v3
On Jul 23, 12:57 pm, Mario <drlenzma...@gmx.de> wrote:
> Hi all,
>
> I want to build an application where GPS data is tracked using an
> Adroid phone, stored on a database and a route following all these
> coordinates is later displayed on the web.

How often do you store the locations?

> Now, I have seen the
> limitation of the DirectionsService causing a MAX_WAYPOINTS_EXCEEDED
> status error, so this won't work with a sufficient number of
> waypoints.

Sufficient being 8 waypoints for the free API and 23 for premier/
enterprise customers:
MAX_WAYPOINTS_EXCEEDED indicates that too many DirectionsWaypoints
were provided in the DirectionsRequest. The maximum allowed waypoints
is 8, plus the origin, and destination. Maps API Premier customers are
allowed 23 waypoints, plus the origin, and destination.

> Using polylines doesn't appear a valid option neither since
> it will not follow roads but rather create straight lines between
> neighboring waypoints.

But if you store enough points it will work.

>
> So, what would be the right way of doing it? Can KML be of any help
> here?

I don't know how that could help.

> Or just send over pairs of neighboring waypoints to the
> DirectionsService, get the routing between these -- and append all the
> various routes as legs server-side on my own?

That would work, but you may run into query limits:
OVER_QUERY_LIMIT indicates the webpage has sent too many requests
within the allowed time period.

-- Larry

Mario

unread,
Jul 25, 2010, 3:16:24 AM7/25/10
to Google Maps JavaScript API v3
> But if you store enough points it will work.

OK, I was rather thinking about storing LESS GPS data points and let
the routing do the rest, e.g. follow roads. Just as you do it when you
use your GPS software to plan a motorbike trip, set some dozen
waypoints, tell it to avoid highways and then let it plan the entire
trip in detail.

Apparently, that doesn't work.

So, the proposal is to store MORE data points and draw polylines,
right?

Thanks,
Mario.

geoco...@gmail.com

unread,
Jul 25, 2010, 11:29:10 AM7/25/10
to Google Maps JavaScript API v3
On Jul 25, 12:16 am, Mario <drlenzma...@gmx.de> wrote:
> > But if you store enough points it will work.
>
> OK, I was rather thinking about storing LESS GPS data points and let
> the routing do the rest, e.g. follow roads. Just as you do it when you
> use your GPS software to plan a motorbike trip, set some dozen
> waypoints, tell it to avoid highways and then let it plan the entire
> trip in detail.
>
> Apparently, that doesn't work.

Unless you can reduce it to 8 waypoints, plus start and destinations.

>
> So, the proposal is to store MORE data points and draw polylines,
> right?

Yes. But it really depends on how accurate your GPS is. You might
find that the points it gives you are not on the roads. If the offset
is consistent, you might need to make an adjustment for it.

You can also probably do some simplification by removing duplicate
points (or points that are really close).

You might also investigate the Douglas-Peucker polyline simplification
algorithm

-- Larry

>
> Thanks,
> Mario.

Barry Hunter

unread,
Jul 26, 2010, 9:29:46 AM7/26/10
to google-map...@googlegroups.com
On 25 July 2010 08:16, Mario wrote:
> So, the proposal is to store MORE data points and draw polylines,
> right?

Also helps avoid the issue where the 'simulated' route doesn't match reality.

Such as the tracked device following a brand new road that is not yet
shown in base map; where the chosen route differs from 'algorithmic'
route; where the basemap is simply wrong (such as two roads not
connecting (in the data) will entail a unneeded (and unreal)
diversion)

... of course that may not actually be an issue - depending on your
intended application.

Reply all
Reply to author
Forward
0 new messages