【问题标题】:Calculate driving directions using PHP?使用 PHP 计算行车路线?
【发布时间】:2009-11-25 22:51:49
【问题描述】:

对于我的应用程序,我需要一个服务器来计算行车路线。

Google Maps API 专为客户端使用而设计,带有 Javascript 和 Flash API。有什么方法可以运行他们的 API 的服务器端?

【问题讨论】:

标签: php scripting google-maps server-side driving-directions


【解决方案1】:

据我所知,这不是官方的,谷歌不支持它,但它可以工作:

$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);

您将在 $data 数组中找到方向。

【讨论】:

  • 我忘了说要编辑客户端以满足您的需求或用 api 密钥替换它
  • 该 URL 从来不是受支持的 API,只是 Google 地图网站的一部分。正确的方法是使用 Directions API(在发布此答案时不可用):developers.google.com/maps/documentation/directions/intro
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-09-14
  • 2013-12-08
  • 1970-01-01
  • 1970-01-01
  • 2017-07-16
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多