Position relative to the Meridian that passes through Greenwich, London
Positive for east. Negative for west.
Single number like 57.7787
Or in degrees+minutes like 57°46.722' N
Or in degrees+minutes+seconds like 57°46'43" N
Distance between two locations
Not as simple as using pythagoras theorem since the earth is not flat
Databases capable of such calculations are called spatial
Direction from one location to another
Also called bearing
Specified in 0-360 degrees where 0 is north, 90 is east, 180 south and 270 west
Determine geolocation on a mobile device
IP to country database
All IPs are registered to a company, located in a known country. Does not always tell the whole truth. IP to country databases are freely available on the net.
WiFi routers broadcast their names and a unique ID. By driving around and collecting all those identifiers and the current position, a database is built. Detecting strength/proximity to those identifiers gives a good accuracy inside of cities with many WiFi routers. Not freely available.
Mobile network triangulation (3G)
Information provided by the phone company (carrier) by also measuring the strength/proximity to mobile network antennas, and knowing where those antennas are located.
GPS - Global Position System
Satellite signals that can be received by a GPS receiver in a mobile device. Usually the best accuracy, but also most demanding on battery.
Available in all modern browsers
Always requires consent from the user before delivering the position to a web application
No specific control over what method is used
Can specify "high" accuracy, but not defined exactly what that would mean.
Determine current location as a one time measurement
Determine location as a continuous movement
Not that reliable in web browsers since any continuous events about location might stop when the user uses other applications (like gets an incoming call)
Use the Geolocation API
Always asynchronous, meaning function will return immediately and you provide a function that the API will call once the location has been determined.
Specify a function to call on success
Specify a function to call on error
Specify other settings for making the determination
The maximum amount of time to wait for a location in milliseconds
The maximum amount of time since a previously retrieved and cached location can be used to report a position. Can be set to Infinity to always use any cached location.
Set to true to enforce using better accuracy. Usually means that we'd like to wait for a GPS position and whatever that might mean with regards to battery use. The final choice of what to do is still up to the specific browser.
Object sent to callback as single argument
The supposed accuracy of the position specified in meters
The altitude in meters above sea level for this position, or null if the browser can't determine this
The direction/heading in which the browser has detected movement (0-360), or null if it is unknown (or no movement detected)
The speed at which the browser has detected movement, in meters per second, or null if it is unknown (or no movement detected)
The time at which the location was determined, in milliseconds from 1970-01-01.
Type of error
Object sent to error callback as single argument
Compare error.code to predefined constants in the error object
The user declined permissions to report the location
The position of the device could not be determined
The length of time specified to getCurrentPosition has elapsed before a location could be determined
When tracking movement
Calls function as soon as position changes
Exactly how often is up to the browser and of course dependant on the detected changes in location.
Same arguments as getCurrentPosition
Store returned value from watchPosition
Identifier that can be used to stop the tracking
To stop the tracking. No more callbacks will be made to the functions in the watchPosition call.
If an error occurs, you have to call watchPosition again
For instance, if the user turns off GPS. That would lead to the error function being called and then you'd need to call watchPosition again (and again) if you want to resume tracking once GPS is turned on again. Can lead to quite complex code.
Use a Google search to show location for a place
Just search for the word "coordinates" and the place/city/town.
Use Google Maps to show a location
Enable "LatLng Tooltip" under "Maps labs" in lower left corner of http://maps.google.com. Then hold down shift key while hovering over the map.