Closed padre closed 6 years ago
Hi @padre,
As per Directions API If you pass coordinates, they are used unchanged to calculate directions. Ensure that no space exists between the latitude and longitude values.
origin=41.43206,-81.38992
Alternatives are to use an address as origin
and destination
or use place_id, see examples below.
` $d['a'] = \GoogleMaps::load('directions')
->setParamByKey('origin', 'Toronto')
->setParamByKey('destination', 'Montreal')
->get();
$d['b'] = \GoogleMaps::load('directions')
->setParam([
'origin' => 'place_id:ChIJ685WIFYViEgRHlHvBbiD5nE',
'destination' => 'place_id:ChIJA01I-8YVhkgRGJb0fW4UX7Y',
'mode' => 'driving',
'waypoints' => 'Charlestown,MA|Lexington,MA',// can also be given as an array ['Charlestown,MA','Lexington,MA']
'alternatives' => true,
'avoid' => 'ferries',
'units' => 'metric',
'region' => 'GB',
'departure_time' => 'now',
])
->getResponseByKey('routes.legs.steps.html_instructions');
`
Regards, Alexander
You're right. It's working properly.
Thank you very much.
Glad to hear that all resolved!
Hi,
if I try:
\GoogleMaps::load('directions') ->setParam([ 'origin' => "Barcelona, ES", 'destination' => "Madrid, ES", ]) ->get();
works properly.
When I try:
\GoogleMaps::load('directions') ->setParam([ 'origin' => ['lat' => 41.3850639, 'lng' => 2.1734035], 'destination' => ['lat' => 40.4167754, 'lng' => -3.7037902], ]) ->get();
the response is:
{"geocoded_waypoints":[{"geocoder_status":"ZERO_RESULTS"},{"geocoder_status":"ZERO_RESULTS"}],"routes":[],"status":"NOT_FOUND"}
Someone has been able to use directions API with lat/lng parameters?
Thanks.