Ability to generate routes that do NOT cross country borders

5,169 views
Skip to first unread message

Marky1124

unread,
Feb 3, 2012, 5:12:26 AM2/3/12
to Google Maps JavaScript API v3
Hi,

I have the need to generate travel routes that do NOT cross country
borders. I can't see the ability to do that automatically in the
Google Maps API nor on the Google Maps website. Here is an example
route that starts and finishes in Switzerland but travels through
Germany:

http://maps.google.com/maps?saddr=Rossberghof,+Rossberg,+Wilchingen,+Switzerland&daddr=Fries,+Wil,+Switzerland&hl=en&ll=47.62676,8.548737&spn=0.132352,0.333023&sll=47.602459,8.604012&sspn=0.132414,0.333023&geocode=FQpE1wId4e6BACmTlJO5w3uQRzEiK6JZKSuscw%3BFRJF1gIdvSCCACkN-0EFW3eQRzHs7TE_4A3_WQ&oq=Fries,+sw&mra=ls&t=m&z=12

This route takes 21 minutes, but for legal reasons I can not use it,
so the alternate route that stays in Switzerland takes 65 minutes:

http://maps.google.com/maps?saddr=Rossberghof,+Rossberg,+Wilchingen,+Switzerland&daddr=47.68941,8.56706+to:47.61723,8.62564+to:Fries,+Wil,+Switzerland&hl=en&ll=47.639022,8.453293&spn=0.422873,0.837021&sll=47.646887,8.563156&sspn=0.393203,1.056747&geocode=FQpE1wId4e6BACmTlJO5w3uQRzEiK6JZKSuscw%3BFcKu1wIdFLmCACnNc6lIyH6QRzEALRb0lMNB5g%3BFc6U1gId6J2DACm_h5VtmIKaRzHd1g49soAsrg%3BFRJF1gIdvSCCACkN-0EFW3eQRzHs7TE_4A3_WQ&mra=dpe&mrsp=2&sz=11&via=1,2&t=m&z=11

I need to be able to generate routes that stay in country through the
API. The avoidHighways, avoidTolls and region bias do not appear to
achieve this. I know that a user can use dragging to travel via a
point but I am looking for the route to be generated in country
automatically without relying on the user to customise the offered
route. Have I missed something else? Is it something that perhaps
could be added to the API?

Cheers,
Mark

Rossko

unread,
Feb 3, 2012, 6:49:23 AM2/3/12
to Google Maps JavaScript API v3
> Have I missed something else?

Don't think so, there's no option to do that

> Is it something that perhaps
> could be added to the API?

You can but ask, sounds useful. Create a formal enhancement request
at
http://code.google.com/p/gmaps-api-issues/

I found an existing one
http://code.google.com/p/gmaps-api-issues/issues/detail?id=2698
which is related but not the same functionality, you could 'star' that
as well to express an interest

Marky1124

unread,
Feb 3, 2012, 10:27:36 AM2/3/12
to Google Maps JavaScript API v3
Thank you Rossko. I have taken your suggestion and created Issue 3890.
http://code.google.com/p/gmaps-api-issues/issues/detail?id=3890

Anyone interested in this request please visit the issue and click the
star icon :)

Cheers,
Mark

Dave Medlicott

unread,
Feb 3, 2012, 11:33:28 AM2/3/12
to google-map...@googlegroups.com
I had made the request a while back. I have implemented my own method of determining this by doing the following:

1) Maintain a list of all valid countries
2) In my app, it is ok to cross boundaries for EU countries, so I maintain a list of EU countries as well
3) Use the Directions Service and parse each of the response route(s) legs for the string ">Entering " and slice off the next part of the returned leg
4) We could be entering a state or a country or something else, so check that slice to see if it is a listed country
5) Check to see if the route goes from one EU country to another
6) Here's a good one ... check to see if the start country is the US and the place we're entering is "Georgia". Georgia is the only one I've found so far that we could be ">Entering " as both a country or something else.

I also have to check to see if the route goes on a ferry or a train (get the directions from London to Paris and you'll see what I mean) because of the non-deterministic nature of those routes. I've also asked to have a return for that.

Dave

Marky1124

unread,
Feb 6, 2012, 4:24:48 AM2/6/12
to Google Maps JavaScript API v3
Hi Dave,

Thank you for your reply. You raise some interesting points. I feel I
may be in a similar situation to you. I'm not sure right now but I
suspect that country borders within the EU may be OK, which makes the
whole thing more complicated since some country borders are allowed
and others are not.

I can see how you go about determining that the route you have been
given does or does not cross a non-EU boundary, which means you can
flag up the situation, but I don't see that it gives you the ability
to generate the EU-only, or in-country only, route. In my situation I
will be most interested in evaluating the journey time for different
people to get to a location to judge who is nearest.

I couldn't find your request to add a star to it.

Cheers,
Mark

Dave Medlicott

unread,
Feb 6, 2012, 12:18:07 PM2/6/12
to google-map...@googlegroups.com
Mark,
I just went back and looked and my request was actually for a transportation mode flag (e.g. train, ferry,. jetski ...). We have a premier license, so that's how I submit my change requests. I went back and starred your request.

In my app, the user supplies a destination location (which includes the country) and I have a database of several hundred service locations worldwide and I need to find the one that best meets a set of criteria - one of which is that the drive time must be less than 3 hours and the route cannot include crossing a border (unless it's from an EU country into an EU country) and it can't include a ferry or a train. If I search the database and get a candidate location (i.e. in the same country or they are both in the EU), I then get the driving directions and check each leg for the ">Entering " string and then I evaluation whether I have crossed an invalid international boundary.

I hope that makes sense. I wish I could supply a link, but it's inside our firewall (hence the need for the Premier license).

Thanks, Dave
Reply all
Reply to author
Forward
0 new messages