Google 位置的格式化地址是否唯一?
我希望我们网站的用户能够
- 搜索并选择一个地址或在地图上标记一个位置,
- 决定这个地址/位置的准确度
我正在使用 jquery、jquery ui 的自动完成功能实现第一部分,谷歌地图和谷歌地理编码器。对于第二部分,我将使用 jquery 在客户端基于第一部分的地址元素/替代项生成一个单选按钮列表。
然而,我关心的是如何将选择传达到服务器端。 Google 地理编码器包含许多我想要存储的有用元数据。
- 一种可能性是将完整的 json 对象存储在隐藏的表单字段中,但我不能信任用户。这样的解决方案会导致垃圾邮件不友好地插入到数据中。
- 如果地址/位置有一个唯一的标识符,我可以只存储这些并让服务器重新获取/评估数据。替代的 geonames.org Web 服务也有这样的 id。但是,例如 Google 位置的格式化地址是否唯一?
有什么建议吗?
I want our users of a web site to be able to
- either search and pick an address or mark a location on a map
- decide how accurate this address/location is
I am in the process of implementing the first part with jquery, jquery ui's autocomplete, google map, and google geocoder. For the second part I will generate a radiobutton list based on the address elements/alternatives of the first part on the client side with jquery.
My concern, however, is how to convey the choices to the server side. The Google geocoder includes a number of useful metadata that I want to store.
- A possibility is to store the complete json object in a hidden form field, but I can't trust the users. Such a solution would enable an unfriendly insertion of spam in the data.
- If the addresses/locations would have a unique identifyer I could store just these and let the server refetch/evaluate the data. The alternative geonames.org web service has such ids. But are for example the formatted addresses of a Google location unique?
Any tips?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我所知,Google 地理编码器没有唯一的地址 ID。
为了尽可能快地做出响应,一个选项可能是在您的服务器上添加一个 PHP 文件以充当 Google 地理编码器的代理。用户将搜索参数发送到您的代理脚本,代理脚本可以使用该搜索参数引用 SQL 表(并返回缓存的数据,如果之前已查询过),否则让它与 Google Geocoder API 交互,缓存响应,然后将响应返回给用户。
通过这种方式,您也可以根据缓存的位置数据的密钥发布自己的位置 ID。
To the best of my knowledge, the Google Geocoder does NOT have unique IDs for addresses.
An option, to make the response as quick as possible, might be to add a PHP file on your server to act as a proxy to the Google Geocoder. The user sends the search parameters to your proxy script, which could them reference an SQL table with that search parameter (and return the cached data, if it has been queried before), otherwise have it interact with the Google Geocoder API, cache the response, and then return the response through to the User.
In this way, too, you could issue your own Location IDs based on the key for the cached location data.