Obtain geographic location information and geographical location

Source: Internet
Author: User

Obtain geographic location information and geographical location

In HTML5, A geolocation attribute is added to the window. navigator object. You can use the Geolocation API to access this attribute. The geolocation attribute of the window. navigator object has the following three methods.

Void getCurrentPosition (onSuccess, onError, options );

This method is used to obtain the current geographical location information of a user.

Navigator. geolocation. getCurrentPosition (

Function (position) {}, // when the user's geographical location is obtained successfully, call parameter 1.

Function (error) {}, // call parameter 2 when the user fails to obtain the location

{} // Optional attribute parameter 3

);

Parameter 1: This function has an object whose position parameter has the following attributes:

Latitude the latitude of the current geographic location

Longitude of the current geographic location of longpolling

Altitude current geographic location elevation

Accuracy of the latitude or Longitude obtained by accuracy (in meters)

AltitudeAccuracy

The Forward Direction of the heading device is indicated by the clockwise rotation angle toward the north.

Speed Device forward speed (in meters per second)

Time when timestamp obtains the geographic location

There are many ways to obtain positioning information, including GPS technology, which has the highest precision. In addition, you can also obtain location information through base stations and Wi-Fi hotspots.

For most developers, you only need to call the user's current location. In this case, you can use the getCurrentPosition () mentioned above. To monitor location changes, useWatchPosition ().

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.