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