Google Route Mapping, part 2

Those of you who attended DevCon 2011 in San Diego may recall meeting Andries Heylen of BH&A, who cheerfully answered questions in the FileMaker Visionary Bar. Well, from the sow’s ear demo I posted in part 1, Andries has woven a silk purse (google-route-mapping-part-2), which I am sharing with his permission, and which uses Google “waypoints” to produce an optimized travel route.

Notes from Andries:

  • The google distance API allows you to just send a start point, an end point and some waypoints (or just waypoints works as well) and returns the path to it in XML.
  • In the XML there is a node that has an encrypted path in it that you can send back to the Static Google Maps API, which will return the image. I combined it with putting the markers on it as well, which are just one of the many parameters you can send to the API.
  •  I use some custom functions from Fabrice Nordmann and Andy Knasinski to parse out the XML, and there is the a custom function I made to convert the “content” created by the webviewer on Windows back into some nice XML
  •  The webviewer refreshes on datachanges, which makes this demo so interactive.
  •  The principle of Virtual List is used to show the Directions.

Thank you Andries for generously sharing this with the FileMaker community.

13 thoughts on “Google Route Mapping, part 2

  1. Mardi Kennedy

    Absolutely amazing – both of them.

    Andries’ version is breathtaking and an incredible learning tool for a bunch of techniques.

    Kevin/ Mark’s is a triumph of simplicity.

    Thank you, All!

    Reply
  2. Simone

    Hello to all, very interesting solution, I keep on coming back to this page. But I am not able to implement this solution…what is the method to change the list of directions ? I’d like to use my database address list creating an API for each item, is it possible ? thankss

    Reply
  3. Andries Heylen

    What do you mean? Did you take a look at the “under the hood” tab. It is all about creating the correct URL, and set the webviewer.

    Watch out that you are not allowed to use the google API for “closed” applications. Only application that are freely accessible.

    We use openlayer (based on openstreetmaps) for our commercial solutions.

    Andries

    Reply
    1. Andries

      Hi

      this is certainly possible. The problem lies probably in the URL length which is limited. If you want to overcome this you can first geocode each point which allows you to send more points (as each point takes less space in the URL) to the API.

      Google also provides an API to geocode addresses.

      Andries

      Reply
  4. Matthew

    Hello, would it be possible to establish a route based on a list of address and then have the ability to modify the route suggested via an interactive window? I suppose you could then feed the changes through the directions API to recalculate distance and time?

    Reply
  5. Andries

    Hi Matthew

    the approach taken here does not allow it as we talk to the google maps image API and not the Javascript V3 API.

    If you want that, you need to take a look at it. At the moment I am working on a HTML/Javascript snippet library, and it is an interesting development to add! If it is finished I will put here a comment (but it will take some time as I am really busy at the moment).

    Andries

    Reply
    1. Matthew

      Hi Andries,

      Yes I know the image API only provides images but my problem is that “shortest route” is rarely the best route for what we do. We run a trucking company and road restrictions dictate where we go. I haven’t done java in over 12 years and I’ve never been much of a programmer, I just get by I suppose.

      Having an interactive map where you can drag and pull on the suggested path to then run it through the directions API would be a tool that would be out of this world handy for our planning.

      Thank you for your reply.

      Reply
  6. Justin

    Would it be possible to generate multiple vehicle route scheduling? Like if I had 100 stops and 10 vehicles, I could run a script and have them auto route based on time, distance and a few other rules? Oh, and if you can do this, please contact me, jkmedical57@gmail.com. I’m hiring!

    Reply
  7. becoming a veterinary assistant

    Wow that was strange. I just wrote an really long comment but after I clicked submit my comment didn’t show up.
    Grrrr… well I’m not writing all that over again.

    Anyways, just wanted to say wonderful blog!

    Reply
  8. Graham

    Andries,
    Brilliant functionality, I had a simple, single pin map button for individual records and added a route planner using your methodology, both working fine. Recently both stopped working correctly, not sure exactly when, giving a 500 error.
    A minor tweak to the map URL allows the pins to show now, but I still have been unable to bring back the route information – any ideas what the problem could be?

    Reply
  9. Siroos

    Good day,

    First of all thanks a mill for your sample file. What I am looking for is a webviewer to show multiple addresses on Google maps with different color markers, I have a solution to show them all in red but as I am not a coding person I have no clue how to change their colors.
    I realized that in your file we are able to change the color based on value of a field. I gave it a try and it works for me to shpo only one address with desired color, Here is the url address I used:

    “http://maps.googleapis.com/maps/api/staticmap?size=440×440&path=weight:7 |enc:&markers=&markers=color:”&MainTable::Marker_Color & MainTable::Address & “ID&sensor=false”

    My questions are:

    – How can we zoom in and zoom out?

    – How can we show multiple places on the map with different colors?

    Best regards.

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s