$ ("document"). Ready (function() {getmap (); }); functionGetmap () {//Baidu Map API features varMap =NewBmap.map ("Allmap"); varPoint =NewBmap.point (116.331398,39.897445); Map.centerandzoom (Point,12); varGeolocation =Newbmap.geolocation (); Geolocation.getcurrentposition (function(r) {if( This. getStatus () = =bmap_status_success) {//var mk = new Bmap.marker (r.point);//Map.addoverlay (MK);//Map.panto (r.point); varLNG =r.point.lng; varLat =R.point.lat; GetLocation (LNG, LAT)}Else{alert (' Failed ' + This. GetStatus ()); }},{enablehighaccuracy:true}) } functiongetLocation (LNG, LAT) {varurl = "http://api.map.baidu.com/geocoder/v2/?ak=XXXXXXXXXXXXXXXXXXX&callback=renderReverse&location=" + Lat+ "," +lng+ "&output=json&pois=1"; $.ajax ({url:url, type:' GET ', DataType:' JSONP ',// HereSuccessfunction(Result) {if(Result.status = = 0 ){ $("#location"). HTML (result.result.formatted_address); Nearbystore (LNG, LAT); }Else{ if(Confirm ("Get location failed, do you want to get it again?") ") ) {getmap (); }Else{ return false; } } } }); }
HTML5 gets the user's current geographic location, which is latitude and longitude.