How web apps ask location of mobile device?

后端 未结 4 1575
迷失自我
迷失自我 2021-01-31 20:22

Many modern mobile phones (google nexus one etc.) have some kind of built in location service. when i go to a some website (eg. google.com) that website asks if I\'m willing to

4条回答
  •  执念已碎
    2021-01-31 21:13

    Web applications on iPhone, Android or even certain desktop browsers (some recent versions of Firefox, Chrome and Opera) use the W3C Geolocation API to request your location. Google Gears also supports a similar geolocation API as a plugin for many browsers, but the W3C API is becoming the standard.

    The code to check for support of the API and then request a location is straightforward (if (navigator.geolocation) ...). Some sample code here.

提交回复
热议问题