位置搜索

发布于 2024-09-15 05:19:21 字数 444 浏览 6 评论 0原文

对于我正在构建的网站,我希望用户能够搜索某个位置,但是因为我没有英国的位置列表,所以我用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

离笑几人歌 2024-09-22 05:19:21

我不知道您是否已经看到过这一点,但 Google Search API 中有一个参数允许您指定 搜索边界

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®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:

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®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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文