duanguzhong5776 2010-08-19 08:29
浏览 58

位置搜索

For the site I am building I want the user to be able to search for a location, however because I don't have a list of locations for the UK, I have developed a script in PHP which calls: http://ajax.googleapis.com/ajax/services/search/local in order to get the lat and lon coordinates of this location to store in the database for future use.

This works well apart from if I search for a town, for example Heaton, it brings back the one in Staffordshire rather than the one in Newcastle for example.

The whole reason I'm using the google ajax api is to cut down the google requests per day because I don't want to exceed the daily request limit.

As you can see though, I've hit a brick wall because the search isn't refined enough to bring back the correct location.

Can anyone suggest another way around this? I'm quite stuck. Thanks

  • 写回答

1条回答 默认 最新

  • dongshao8125 2010-08-19 12:10
    关注

    I don't know if you have seen this already, but there is a parameter in the Google Search API that allows you to specify a boundary for the search:

    GeocoderRequest object specification

    The specification for a geocoding request to be sent to the Geocoder.

    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.
    

    In your case I would specify a bounds around northumberland, so something like:

    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)

    might work...? I don't know if this would be relevant to your app though. Good luck!

    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大