views:

665

answers:

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?

+4  A: 

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.

dfilkovi
I forgot to say to edit client to suite your needs or replace it with api key
dfilkovi