【问题标题】:access google map data from php从 php 访问谷歌地图数据
【发布时间】:2010-01-19 12:21:40
【问题描述】:

我想使用 PHP 建立一个点附近所有餐馆的 json_encoded 列表

希望构建一个带有参数的 php 函数:纬度、经度、半径(以米为单位)。并返回一个 json_encoded 列表

我有一个 API 密钥,我使用 js,但我使用服务器端脚本 php 完成了它

请任何人知道怎么做。


我想将列表存储到我的数据库中。

找到了这个但遇到了一些问题http://code.google.com/apis/maps/documentation/mapsdata/developers_guide_protocol.html#Search

那里给出的 url 中的 mapID 和 userID 是什么。

【问题讨论】:

    标签: php json google-maps


    【解决方案1】:

    你有没有想过使用 Ajax 将数据提交给 PHP 脚本,并在 javascript 中使用 PHP 脚本的返回值将数据绘制到地图上。您可以json发送过来的数据。

    【讨论】:

      【解决方案2】:

      查看地理编码 API:http://code.google.com/apis/maps/documentation/geocoding/。您可以使用 file_get_contents 函数从 PHP 调用 API:

      $url = sprintf("http://maps.google.com/maps/geo?q=%s&output=json&key=%s&ll=%s,%s",
              $query, $api_key, $latitude, $longitude);
      $data = json_decode(file_get_contents($url));
      

      【讨论】:

      • 如何添加半径和搜索餐厅。
      • 可以通过传递 'spn' 参数来指定半径(请参阅 API 文档中的 Viewport Biasing)。我不知道如何使用地理编码搜索餐厅。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-27
      • 1970-01-01
      • 2012-03-04
      • 1970-01-01
      • 2017-12-30
      • 1970-01-01
      相关资源
      最近更新 更多