Identify the nearest vehicle with the distance matrix

The distance matrix API works by taking a list of origin locations and a list of destination locations, either of which could be used for the customer or vehicles depending on the viewer of the application (the origin might be the vehicle looking for customers or the customer looking for vehicles).

Origins and destinations can be specified as coordinate pairs or as addresses, the latter will be matched when the service is called.

As with the Google Directions API, the Distance Matrix API can specify parameters to generate results based upon current traffic from the location of the vehicle.

The following URL shows the call between a person standing at Euston Station and a number of vehicles on surrounding roads.
https://maps.googleapis.com/maps/api/distancematrix/json?units=imperial&origins=51.527699,0.132660&destinations=51.525950,0.136454|51.525571,0.128854|51.529131,0.131603

Responses from the Distance Matrix API consist of a simple match between the origin and destination and the time-resolved.

On Android you can use the Client Libraries to easily connect to the web services, this is especially useful if you are using the Google Maps API on the Premium Plan where a proxy service should be used to contain the cryptographic key that is used when authenticating access to the web service and should not be shared within a mobile application directly. You can find out more at the following resource:
https://developers.google.com/maps/web-services/client-library#requirements

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *