Level: Beginner, Version: FM 8 or later

Google Route Mapping, part 1

The other day someone asked a question on the FMP Experts list about plotting a driving route in Google Maps using FileMaker data.

Mark Rubenstein posted a simple solution, and my reactions were, in this order: “No way, it can’t possibly be this easy; I should build a demo (google-route-mapping) to find out; wow, it really works… hey, I wonder if he’d be okay with me posting this on FileMaker Hacks?”

So I asked him, and it turns out that a) he is, so b) I have. Here’s what Mark posted:

…and with a few minor code tweaks, that’s what you’ll find in the demo.

17 thoughts on “Google Route Mapping, part 1”

  1. Now I was hoping the “minor code tweaks” included an (almost) optimal solution to the traveling salesman problem (by re-arranging the destination points (B-F) to minimize the distance traveled along the route).

  2. What are all the plus signs doing in the concatenated URL? They serve no purpose.

    If your directions are long you may approach the (approx) 1000 character limit on URLs set by Google’s server. In that case you may also remove all the spaces after the commas too.

  3. In my testing of this technique, I’ve been restricted to 25 addresses, which admittedly is plenty for a route. For those 25 addresses the URL had 1,117 characters. This makes it look to me as though the 1000 characters in a URL is not the limitation.

    For a mapping task that requires more addresses and does not require routing, I’m finding that http://www.BatchGeo.com is better suited to my needs.

  4. Very nice. Thanks to you and Mark for the code.

    I changed part of the Plot Route script to use the List function where you set the variable $addresses. It eliminates excess comma chars if by chance the address entry only has a city and state or maybe has all fields except a zip, etc. Google maps doesn’t seem to mind either way though. Don’t even need the Let structure if you don’t want to. I tend to like it for readability as much as anything.

    $addresses &
    Let (
    [
    _v1 = List ( customers::Address ; customers::City ; customers::State ; customers::Zip ) ;
    _v2 = Substitute ( _v1 ; “¶” ; “,” )
    ];
    _v2 & If ( Get ( RecordNumber ) < Get( FoundCount ) ; " to:" ; "" )
    )

  5. Hi Kevin.

    Thank you for share this, it’s really amazing.
    I’ve tried it on the Japanese version of Google Maps and it works.

    Thank you very much for your posts. :-)

    1. Andries

      Were you able to add the optimize to the script? I not quite sure how I would add it. Gave it about two hours.

  6. When I follow the steps, it comes out to a blank google maps page. What must I be doing wrong for it to not pick up the addresses I selected for it?

  7. I wrote this script to plot places on a map where my artists have toured in the last year. dont actually need it routed, just need to see points on the map. Either way, I get an error that it couldnt be done because “my query has too many addresses.” I need to put upwards of 150 points on the map at a time. Any suggestions? Thanks!

  8. Hi, thank you for the idea, I used it for starting a script with my DB, however I need to plot information on every markers. I also need to plot multiple marker without the route. Is it possible using just the url or it is necessary to act on the html page?
    Please help me or give some tips if you can!

  9. Re: the Traveling Salesman problem.

    Is there a rewrite of the script to add optimization to the list?

    referring to:

    Andries Heylen February 13, 2012 at 2:54 am #

    Nice example. I am using Googles webservice a lot. If you pass the extra parameter: “optimize=true”, GoogleMaps will automatically calculate the shortest route to pass trough all the waypoints.

    For more information:
    http://code.google.com/apis/maps/documentation/directions/#DirectionsRequests and look for “Travelling salesman problem”

Leave a Reply to WillCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.