How do I detect user's location from a webpage opened in the Android browser?

别说谁变了你拦得住时间么 提交于 2019-12-12 08:56:30

问题


Visiting www.google.com on the Android browser (or even with an android spoofed user-agent), presents the option to "Share Location". When clicked, it uses the GPS/Cell phone towers to figure out the location. I tried the google.loader.clientLocation but that only works using the IP address.

Is there a method to tap into the Android OS and access GPS data from a regular web application (and not an Android application) similar to the way Google does?

[Perhaps Google uses the Google Gears app on Android to access this data.]

Thanks!


回答1:


I was trying that recently and found this forum posting interesting. I did not find a real good way to do this either and it doesn't look like we can do that without writing our own app which opens a browser instance. http://androidforums.com/support/8868-how-get-gps-coordinates-browser.html




回答2:


This is an HTML5 API, and it'll work on Webkit-derivatives, Chrome, and Firefox 3.5 (for now).

  • http://dev.w3.org/geo/api/spec-source.html
  • http://merged.ca/iphone/html5-geolocation



回答3:


Here is also a nice example: http://klauskjeldsen.dk/w3c-geolocation-api-html5/



来源:https://stackoverflow.com/questions/1959141/how-do-i-detect-users-location-from-a-webpage-opened-in-the-android-browser

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