In HTML5, a new geolocation property has been added to the Window.navigator object, which can be accessed using the Geolocation API. The Geolocation property of the Window.navigator object has the following three methods.
void GetCurrentPosition (onsuccess,onerror,options);
This method is used to obtain the user's current geo-location information.
Navigator.geolocation.getCurrentPosition (
function (position) {},//When the user's geo-location gets a successful call???? Parameter One
Function (Error) {},//When the user acquires a geo-location failed call???????? Parameter two
{}//optional attribute???? Parameter three
);
Parameter one the function has a parameter position is an object that has the following properties:
Latitude latitude of the current geographic location
Longitude longitude of current geographic location
Altitude altitude of the current location
Accuracy the precision of the latitude or longitude obtained (in meters)
Altitudeaccuracy accuracy of altitude
The forward direction of the heading device is represented by a clockwise rotation angle facing the north direction.
Speed device advance (in meters per second)
Timestamp time to get a location
There are many ways to get location information, the highest precision is the number of GPS technology, in addition to the base station and WiFi hotspots and other ways to obtain the location.
For most developers, many times only need to invoke the user's current location, this time can use the above mentioned GetCurrentPosition (), if you need to monitor the location changes, with watchposition ().
Get geo-location information