2 Replies Latest reply on Apr 10, 2014 3:58 PM by rmittelman

    Distance Between 2 Addresses


      I am using the Invoices starter solution, which automatically maps the address you've typed in. This functionality also is in the Contacts starter solution. Both solutions use the custom GetMap function.


      My customer has asked if the driving distance between their address and their customer's address could be also included.

      I know this is possible, as I found http://webdesignandseo.net/scripts/distance/ which lets you type in 2 addresses and calculate the mileage between them.


      Could anybody suggest how I would do this? Presumably it should be done in a separate control than the default one, because they ship all across the country, and the map would probably not scale well if it had to show the entire US. The site above shows the google map with the purple line showing the route, but it also shows the driving mileage above the map. This is the one I'm interested in, not necessarily the map itself.


      Is there a way to leverage the Google Maps API to just get that distance?



        • 1. Re: Distance Between 2 Addresses

          Yes, there is way to use some of the Google Maps APIs to do this, but you don't necessarily have to invoke an actual map. I wrote a blog post about it back in November. The example in the blog post gets distance with coordinates as the starting location and an address for the final destination, but there's no reason they can't both be addresses.

          • 2. Re: Distance Between 2 Addresses

            Thanks, @jbante. This is just what I'm looking for.  The distance "as the crow flies" works right out of the box on your solution. Unfortunately, I can't get the transit distance to work. I hit the little compass button, which I realized too late was the "get my location" button for iOS. So, I looked up my own coordinates and pasted them in those fields (- for west longitude or south latitude, right?). Again, the direct distance works fine. Either my internet connection doesn't work properly to call the web service, or something.  I will check with my customer, maybe the straight-line method will be fine for them. They ship merchandise, and want approximate distance from our place to theirs. Thought road distance would be better, but I will see.


            BTW, is there a way to send a parameter to get miles instead of meters?  If not, easy enough to convert result.


            Thanks again...