Calculate driving directions using PHP?
Asked Answered
W

1

1

For my application I need a server to calculate driving directions.

The Google Maps API was designed for clientside use only, with a Javascript and Flash API. Is there any way I can run their API's server-side?

Wheezy answered 25/11, 2009 at 22:51 Comment(2)
Hi, Does it have to be Google Maps, or could you use Bing Maps instead? If the latter, you could check the Bing Maps SDK (microsoft.com/maps/developers) as it provides a SOAP webservice, which I presume can be called from a server.Exaggerate
Possible duplicate of Google Maps HTTP API for driving and walking directionsIntra
J
7

As I know it this isn't official and google doesn't support it but it works:

$url = str_replace(' ', '%20', "http://maps.google.com/maps/nav?client=yourclient&output=json&q=from: ".$lat1.",".$lon1." to: ".$lat2.",".$lon2);

$result = file_get_contents($url);
$data = json_decode(utf8_encode($result), true);

And you'll have directions in $data array.

Juliannajulianne answered 25/11, 2009 at 23:22 Comment(2)
I forgot to say to edit client to suite your needs or replace it with api keyJuliannajulianne
That URL was never a supported API, just parts of Google Maps site. The correct way is to use the Directions API (not available at the time this answer was posted): developers.google.com/maps/documentation/directions/introIntra

© 2022 - 2024 — McMap. All rights reserved.