System to measure distance between 2 locations on my website

Good Morning,

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

Author: M_b_85, 2016-07-29

1 answers

One of the options is to use API do Google Maps. In it returns the distance between two addresses and the average time it takes 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"
}

Follows a nice tutorial I found:

Http://cbsa.com.br/post/distancia-entre-cidades---google-maps-javascript-api-v3.aspx

 1
Author: Matheus, 2016-07-29 11:59:30