Calculate driving directions using PHP?

久未见 提交于 2019-11-27 07:35:02

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/1800510/calculate-driving-directions-using-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!