Get geo-location information

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.