0 votes

Distance Matrix Matrix API Help - Google Maps

I would like to know if with the distance API - Google Maps it is possible to calculate the distance of a city between others in one go.

For example: calculate the distance from New York to Paris, from New York to Beijing, from New York to Madrid?

And if not, how can I do with php to take the response from the following URL and save only the KM:

http://maps.googleapis.com/maps/api/distancematrix/json?origins=Porto%20alegre&destinations=Rio%20de%20Janeiro&language=pt-BR&sensor=false

{
    "destination_addresses" : [ "Rio de Janeiro, Rio de Janeiro - RJ, Brasil" ],
    "origin_addresses" : [ "Porto Alegre, Porto Alegre - RS, Brasil" ],
    "rows" : [
    {
        "elements" : [
        {
            "distance" : {
                "text" : "1.570 km",
                "value" : 1570193
            },
            "duration" : {
                "text" : "18 horas 5 minutos",
                "value" : 65097
            },
            "status" : "OK"
        } ]
    } ],
    "status" : "OK"
}

I need this in order to verify if there is a distance of less than 50km between one location and another.

1voto

Luis Moreno Points 44

Yes, it is possible, only that the calculation will be made between the points registered as the center of the city, without taking into account the real distance between the exit of the first city and the entrance of the second one.

HolaDevs.com

HolaDevs is an online community of programmers and software lovers.
You can check other people responses or create a new question if you don't find a solution

Powered by:

X