Google Maps: Difference between revisions
Jump to navigation
Jump to search
(7 intermediate revisions by the same user not shown) | |||
Line 7: | Line 7: | ||
* [[Google#Subjects|Google]] | * [[Google#Subjects|Google]] | ||
=Distance API= | =Distance Matrix API= | ||
Playground Example | ==Overview== | ||
The Google Maps Distance Matrix API is a service that provides travel distance and time for a matrix of origins and destinations. In the simplest case, a start address and a destination address are sufficient. | |||
==Playground Example== | |||
<blockquote style="background-color: AliceBlue; border: solid thin LightSteelBlue;"> | <blockquote style="background-color: AliceBlue; border: solid thin LightSteelBlue;"> | ||
:<br>https://github.com/NovaOrdis/playground/tree/master/google/maps/distance<br><br> | :<br>https://github.com/NovaOrdis/playground/tree/master/google/maps/distance<br><br> | ||
</blockquote> | </blockquote> | ||
Build and execute the example: | |||
<pre> | |||
mvn package exec:java | |||
</pre> | |||
Request URL example: | Request URL example: | ||
<pre> | <pre> | ||
https://maps.googleapis.com/maps/api/distancematrix/json?origins=800+Alma+Street+Menlo+Park+CA+94025&destinations=585+Franklin+St+Mountain+View+CA+94041&key=... | https://maps.googleapis.com/maps/api/distancematrix/json?origins=800+Alma+Street+Menlo+Park+CA+94025&destinations=585+Franklin+St+Mountain+View+CA+94041&units=imperial&key=... | ||
</pre> | </pre> | ||
Line 24: | Line 34: | ||
<pre> | <pre> | ||
{ | |||
"destination_addresses" : [ "585 Franklin St, Mountain View, CA 94041, USA" ], | |||
"origin_addresses" : [ "800 Alma St, Menlo Park, CA 94025, USA" ], | |||
"rows" : [ | |||
{ | |||
"elements" : [ | |||
{ | |||
"distance" : { | |||
"text" : "9.5 mi", | |||
"value" : 15270 | |||
}, | |||
"duration" : { | |||
"text" : "18 mins", | |||
"value" : 1108 | |||
}, | |||
"status" : "OK" | |||
} | |||
] | |||
} | |||
], | |||
"status" : "OK" | |||
} | |||
</pre> | </pre> |
Latest revision as of 08:39, 23 January 2016
External
Internal
Distance Matrix API
Overview
The Google Maps Distance Matrix API is a service that provides travel distance and time for a matrix of origins and destinations. In the simplest case, a start address and a destination address are sufficient.
Playground Example
Build and execute the example:
mvn package exec:java
Request URL example:
https://maps.googleapis.com/maps/api/distancematrix/json?origins=800+Alma+Street+Menlo+Park+CA+94025&destinations=585+Franklin+St+Mountain+View+CA+94041&units=imperial&key=...
Response example:
{ "destination_addresses" : [ "585 Franklin St, Mountain View, CA 94041, USA" ], "origin_addresses" : [ "800 Alma St, Menlo Park, CA 94025, USA" ], "rows" : [ { "elements" : [ { "distance" : { "text" : "9.5 mi", "value" : 15270 }, "duration" : { "text" : "18 mins", "value" : 1108 }, "status" : "OK" } ] } ], "status" : "OK" }