获取用户输入的确切位置
我建立了一个 PHP 网站,帮助用户组织他们的活动。
系统的一个重要部分是定义事件位置,该位置通常是创建事件的人的家庭位置。
我正在尝试创建一种方法,允许用户通过在某种地图上选择这些地点来将“地点”添加到他们的个人资料中,或者可能采用文本字符串并将其显示在地图上(如何避免人们拼写错误? )。
同样重要的是,该服务应该允许来自世界各地的地址。
有没有人做过类似的事情或有任何解决方案?
I have built a PHP website that helps its users to organize their events.
An important part of the system is defining the event location, which will usually be the home location for the person creating the event.
I am trying to create a way to allow a user to add 'places' to their profile by selecting those places on some sort of a map, or maybe take a textual string and show it on a map (how do I avoid people misspells?).
Also important, the service should allow addresses from all over the world.
Has anyone ever done something like this or has any solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
听起来您只需要与地图服务集成,例如 Google 地图 或Bing 地图。
您可以在本地保存用户创建的“地点”的数据库,并将它们显示为地图上的叠加层。地址和纬度/经度坐标都是可用的,并且通常可以通过 API 互换。 (每个提供的搜索都可以很好地处理拼写错误。)
Sounds like you just need to integrate with a mapping service, such as Google Maps or Bing Maps.
You'd locally keep a database of the "places" created by users and display them as overlays on the maps. Addresses and lat/long coordinates are both usable, and generally interchangeable through the API. (And the search provided by each handles spelling mistakes pretty well.)
使用 Google 地图 API?实际上,与之交互非常容易。您应该在示例。
您可以将位置存储在数据库中,当用户打开地图时,将其位置加载到地图上。 Google 还有一个(反向)地理编码 服务。有一些替代方案您不需要依赖 Google,例如借助免费数据(例如 OpenStreetMap)构建您自己的 GeoService。这需要大量资源,因此对于项目的开始,我认为 Google 就很好。
Using Google's Maps API? It's actuall pretty easy to interact with it. YOu should find something in the Examples.
You could store the locations inside your database and when the user opens the map, load his locations onto the map. Google also has a (Reverse-) GeoCoding service. There are some alternatives available that you do not need to rely on Google like building your own GeoService with the help of free data (like OpenStreetMap). This takes lots of ressources so for the start of the project, I think Google is just fine.