HTML5 location, html5 location

Source: Internet
Author: User

HTML5 location, html5 location

1. Use navigator. geolocation to obtain the current location of the device. Return a location object to obtain information about the current longitude and latitude;

2. Three Methods of navgatior. geolocation:

GetCurrentPosition ();

WatchPosition ();

ClearWatch ();

3. getCurrentPosition () Usage

Navigator. geolocation. getCurrentPosition (successCallback, [errorCallback], [positionOptons]);

A) SuccessCallback: gets the callback function eg: function (position) {alert ("latitude:" + position. coords. latitude + "; longitude:" + position. coords. longpolling )};

SuccessCallback returns a geographic data object position as the parameter, which has the attributes timestamp and coords. Timestamp indicates the Geographic Data creation time (timestamp). coords includes the following seven attributes:

1. coords. latitude: Estimated latitude
2. coords. longpolling: Estimated longitude
3. coords. altitude: Estimated height
4. coords. accuracy: accuracy of latitude and longitude estimates in meters
5. coords. altitudeAccuracy: accuracy of the provided height estimates in meters
6. coords. heading: The angle direction of the current movement of the host device, clockwise relative to the north direction


7. coords. speed: current local speed of a device in meters per second

Related Article

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.