System to measure distance between 2 locations on my website

2

Good morning,

I'm making a website where users need to calculate the distance between 2 locations. Does anyone know how or where can I use a system that allows me to do this on my website?

    
asked by anonymous 29.07.2016 / 10:41

1 answer

1

One of the options is to use API do Google Maps . It returns the distance between two addresses and the average time between the two points.

Ex:

http://maps.googleapis.com/maps/api/distancematrix/json?origins=99010030&destinations=99064090&mode=driving&language=pt-BR&sensor=false

Response:

{
   "destination_addresses" : [ "São Cristovao, Passo Fundo - RS, 99064-090, Brasil" ],
   "origin_addresses" : [ "Vila Popular, Passo Fundo - RS, 99010-030, Brasil" ],
   "rows" : [
      {
         "elements" : [
            {
               "distance" : {
                  "text" : "4,7 km",
                  "value" : 4656
               },
               "duration" : {
                  "text" : "11 minutos",
                  "value" : 652
               },
               "status" : "OK"
            }
         ]
      }
   ],
   "status" : "OK"
}

Here's a cool tutorial I found:

link

    
29.07.2016 / 13:59