How does the HTML5 Geolocation API work?

2019-09-10 23:47发布

I am wondering how the HTML5 Geolocation API works. What I need to know is, the obtained latitude and longitude belongs to whom? Is it the location of the ISP, as I think there is no GPS device attached to my PC or the laptop? Also if it is obtained from the SSID of the WiFi device? Does the WiFi device know it's coordinates?

1条回答
你好瞎i
2楼-- · 2019-09-11 00:38

From the W3C Geolocation API Specification (emphasis mine):

The Geolocation API defines a high-level interface to location information associated only with the device hosting the implementation, such as latitude and longitude. The API itself is agnostic of the underlying location information sources. Common sources of location information include Global Positioning System (GPS) and location inferred from network signals such as IP address, RFID, WiFi and Bluetooth MAC addresses, and GSM/CDMA cell IDs, as well as user input. No guarantee is given that the API returns the device's actual location.

Your browser will use the hardware provided to it by "the device hosting the implementation," but neither consistency nor accuracy are guaranteed.

查看更多
登录 后发表回答