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?

Robin Rodricks
  • 110,798
  • 141
  • 398
  • 607
  • 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 (http://www.microsoft.com/maps/developers/) as it provides a SOAP webservice, which I presume can be called from a server. – keyboardP Nov 25 '09 at 23:13
  • Possible duplicate of [Google Maps HTTP API for driving and walking directions](http://stackoverflow.com/questions/2041601/google-maps-http-api-for-driving-and-walking-directions) – miguev Jul 07 '16 at 10:21

1 Answers1

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.

dfilkovi
  • 3,051
  • 7
  • 39
  • 51
  • 1
    I forgot to say to edit client to suite your needs or replace it with api key – dfilkovi Nov 25 '09 at 23:29
  • 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): https://developers.google.com/maps/documentation/directions/intro – miguev Jul 07 '16 at 10:18