Geolocation location changes
Over the last few days I've been working on a project involving geolocation in HTML5 and I've become familiar with the concept. This demo as well as a similar example that forms part of my project has always been accurate in determining my location to a few hundred metres. However, as o开发者_JAVA技巧f just now they all plot me as being in the nearest large city. For my project it is important that the location remains constant - what could have prompted this?
Location information can be sourced from 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.
It depends on what device you're testing and where it is sourcing geolocation data from. IP address lookups may change as databases are constantly updated, or a shared IP address will change depending on user input from other users. An accurate GPS fix may not be available right now. Your device temporarily switched cell towers. Etc...
If accuracy is your primary concern then use watchPosition
instead of getCurrentPosition
and monitor the accuracy
of the returned position, only update when that drops below your threshold.
精彩评论