How can I get the GPS location for use in a website?

孤街浪徒 提交于 2019-12-11 14:49:57

问题


I am developing a website that needs to know the user's location. All of the users will be employees of the company; there's no tracking of customers or anything like that. The users will be employees out in the field. They could be on Android phones, iPhones, tablets, or laptops. I've found several ways to get their location, but can't find specific ways to get that location back to our website. Ideally, we'd like the user's location to be reported to database and the website would get that location when they login. Below are some ways I've researched to accomplish this. How do I get any of this information into my website?

  1. Personal GPS tracker (like this: http://www.ezoomgps.com/home.aspx). These devices seem to let employers track employees via a map and have other features, but all we need to know is the location (latitude and longitude). Anyone know how to get a device like this to report those coordinates for use in a website?
  2. Mobile app. Lots of apps out there for showing locations on a map, but nothing that just takes the location and reports it to a database/website. Anyone know of an app that just reports the devices location?
  3. IP tracing. Found some IP tracing services (like http://www.ip2location.com/), but not sure how well they work on mobile. Tried some with my phone and it got my city name right, but couldn't pinpoint my location. Anyone know an accurate way to get a physical location from an IP address?

回答1:


Sounds like a job for navigator.geolocation.getCurrentPosition in HTML5. That would be reasonably cross-platform and you could build it into web pages that report back to your database.

See:

  • http://html5demos.com/geo
  • http://www.w3.org/TR/geolocation-API/
  • http://diveintohtml5.info/geolocation.html



回答2:


if i understood the idea, why not simply consume a webservice from the phone with the info?



来源:https://stackoverflow.com/questions/19799385/how-can-i-get-the-gps-location-for-use-in-a-website

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!