Get a location
<!DOCTYPE HTML><HTMLLang= "en"><Head> <MetaCharSet= "UTF-8"> <title>Title</title></Head><Body><Script> //compatible processing if(navigator.geolocation) {//Successcallback When getting the user's location successful callback function //Errorcallback callback function when getting the user location failednavigator.geolocation.getCurrentPosition (Successcallback, errorcallback); } Else{Console.log ('Sorry, your browser does not support geo-targeting'); } //get a geographically successful callback function functionSuccesscallback (position) {//get the current latitude and longitude of the user //coords coordinates //Latitude Latitude varWD=Position.coords.latitude; //Longitude Longitude varJD=Position.coords.longitude; Console.log ("Get user Location success! "); Console.log (WD+ '----------------' +JD); } //get callback function for geo-location failure functionErrorcallback (Error) {Console.log (error); Console.log ('failed to get user location! ') }</Script></Body></HTML>
Geographic coordinates crawl
http://api.map.baidu.com/lbsapi/getpoint/index.html
Baidu API Show
<HTML><Head> <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8" /> <Metaname= "Viewport"content= "initial-scale=1.0, User-scalable=no" /> <styletype= "Text/css">Body, HTML{width:100%;Height:100%;margin:0;font-family:"Microsoft Jas Black";}#l-map{Height:300px;width:100%;}#r-result{width:100%;} </style> <Scripttype= "Text/javascript"src= "http://api.map.baidu.com/api?v=2.0&ak= your Key"></Script> <title>Results panel for Local Search</title></Head><Body><DivID= "L-map"></Div><DivID= "R-result"></Div></Body></HTML><Scripttype= "Text/javascript"> //Baidu Map API features varMap= NewBmap.map ("L-map"); //Create a Map instanceMap.centerandzoom (NewBmap.point ( the, 39.915), -); varLocal= NewBmap.localsearch (map, {renderoptions: {map:map, Panel:"R-result"} }); Local.search ("Dining");</Script>
html5--Location