【问题标题】:Location searching位置搜索
【发布时间】:2010-08-19 08:29:06
【问题描述】:

对于我正在构建的网站,我希望用户能够搜索位置,但是因为我没有英国的位置列表,所以我用 PHP 开发了一个脚本,它调用:http://ajax.googleapis.com/ajax/services/search/local为了得到这个位置的纬度和经度坐标以存储在数据库中以备将来使用。

这很有效,如果我搜索一个城镇,例如希顿,它会带回斯塔福德郡的城镇,而不是纽卡斯尔的城镇。

我使用 google ajax api 的全部原因是为了减少每天的 google 请求,因为我不想超过每日请求限制。

正如您所见,我遇到了困难,因为搜索不够精细,无法返回正确的位置。

谁能提出另一种解决方法?我很困惑。谢谢

【问题讨论】:

    标签: php json google-maps location google-api


    【解决方案1】:

    我不知道你是否已经看过这个,但是在 Google Search API 中有一个参数可以让你指定a boundary for the search

    GeocoderRequest 对象规范

    地理编码规范 请求发送到地理编码器。

    Properties  Type         Description
    address     string       Address. Optional.
    bounds      LatLngBounds LatLngBounds within which to search. Optional.
    language    string       Preferred language for results. Optional.
    location    LatLng       LatLng about which to search. Optional.
    region      string       Country code top-level domain within which to search.
    

    在你的情况下,我会指定诺森伯兰周围的界限,比如:

    http://ajax.googleapis.com/ajax/services/search/local?q=heaton&v=3.1&region=GB&sensor=false&bounds=(55.395,%20-2.510%20,2054.342,%20-0.417)

    可能有用...?我不知道这是否与您的应用相关。祝你好运!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-08
      • 2016-09-16
      • 1970-01-01
      • 1970-01-01
      • 2022-01-07
      相关资源
      最近更新 更多