位置搜索
对于我正在构建的网站,我希望用户能够搜索某个位置,但是因为我没有英国的位置列表,所以我用 PHP 开发了一个脚本,该脚本调用: http://ajax.googleapis.com/ajax/services/search/local 以获得该位置的经纬度坐标存储在数据库中以供将来使用。
如果我搜索一个城镇(例如希顿),它会带回斯塔福德郡的城镇,而不是纽卡斯尔的城镇,这很有效。
我使用 google ajax api 的全部原因是为了减少每天的 google 请求,因为我不想超出每日请求限制。
但正如您所看到的,我遇到了困难,因为搜索不够精细,无法返回正确的位置。
谁能建议另一种方法来解决这个问题?我很困惑。谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道您是否已经看到过这一点,但 Google Search API 中有一个参数允许您指定 搜索边界:
在您的情况下,我会指定诺森伯兰周围的边界,例如:
http://ajax.googleapis.com/ajax/services/search/local?q=heaton&v=3.1®ion=GB&sensor =false&bounds=(55.395,%20-2.510%20,2054.342,%20-0.417)
可能有效...?我不知道这是否与您的应用程序相关。祝你好运!
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:
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®ion=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!