The Distance Matrix API uses widop/http-adapter which is a PHP 5.3 library for issuing http requests.
The Google Distance Matrix API is a service that provides travel distance and time for a matrix of origins and destinations. The information returned is based on the recommended route between start and end points, as calculated by the Google Maps API, and consists of rows containing duration and distance values for each pair.
This service does not return detailed route information. Route information can be obtained by passing the desired single origin and destination to the Directions API.
By default, the bundle doesn't need any configuration. Most of the service have a default configuration which allows
you to use the given objects like they are. The fungio_google_map.distance_matrix
service is not one of them. The
configuration describes below is this default configuration but if you don't provide at least one value (for the
distance_matrix
or distance_matrix_request
nodes), the service will not be registered.
# app/config/config.yml
fungio_google_map:
distance_matrix:
# Enable the service
enabled: true
# Your own directions class
class: "My\Fucking\DistanceMatrix"
# The http adapter
adapter: "widop_http_adapter.curl"
# The Directions API URL
url: "http://maps.googleapis.com/maps/api/distancematrix"
# TRUE if the service uses HTTPS else FALSE
https: false
# The format used (json or xml)
format: "json"
$distanceMatrix = $this->get('fungio_google_map.distance_matrix');
If you want to use it with a business account, you can read this documentation.
$response = $distanceMatrix->process(array('Vancouver BC'), array('San Francisco'));
The distance matrix allows you to process a much more advanced request. If you want to lear more, you can read this documentation.
When you have requested your distance matrix, the returned object is an
Fungio\GoogleMap\Services\DistanceMatrix\DistanceMatrixResponse
. If you want to learn more about the response, you
can read this documentation.