html5-Geo-positioning

Source: Internet
Author: User

Geolocation: geo-Locate, get the geographic coordinates information (including longitude, latitude, altitude, movement speed) of the current browser, achieve LBS application (Location Based service)-based on positioning services, such as ordering, face-to XX, navigation, message push and so on. Official website: http://lbsyun.baidu.com/

Technically how to get the geographic coordinates of your browser:

(1) Mobile browser:

The GPS chip can be used to communicate with the satellite--precisely at the m level;

Mobile communication base station can also be used to locate-precision at the KM level

(2) PC Browser:

Reverse derivation of browser location information by IP address--accuracy at km level

HTML5 provides a new object that is designed to read geo-location information:

window.navigator.geolocation {

GetCurrentPosition (): Get current positioning information

Watchposition (): Monitoring changes in location data

Clearwatch (): Clear location monitoring

}

Core code:

1 Navigator.geolocation.getCurrentPosition (2 3        function(POS) {//Positioning Success4 5 Console.log (Pos.timestamp)6 7Console.log (Pos.coords.longitude/latitude/altitude/speed);8   },9 Ten   function(ERR) {//failed to locate One  AConsole.log (Err.code +err.message); -  -  } the  -);

Embed Baidu map in your own web page to achieve the following steps:

(1) introduction of Baidu Map Application js file in the page

<script src= "http://api.map.baidu.com/api?v=2.0&ak= your Key" >

</script>

(2) write code, call Baidu Map API, display the map content in your own web page

var map = new Bmap.map ("container");

var point = new Bmap.point (116.300982,39.916078);

Map.centerandzoom (Point, 17);

Complete code example:

<! DOCTYPE html> 

  

Baidu Map Related plugins: Https://github.com/HLJMT

html5-Geo-positioning

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.