Today, the development of applications, access to geographical location, the first use of H5 geolocation method to obtain a geographical location, the test found that the Android machine can, but the iOS is not, a check data only know: 10.0 Apple version requires protocol for HTTPS to get to geo-location. Then in order to solve this problem, use Baidu Map to obtain, the specific steps and code are as follows:
1. Open http://lbsyun.baidu.com/Baidu Map open Platform
2. Development--"JAVASCRIPTAPI, click to get the key, register to get the key
3. The final complete code
<!DOCTYPE HTML><HTML><Head> <MetaCharSet= "UTF-8"> <Scripttype= "Text/javascript"src= "http://api.map.baidu.com/api?v=2.0&ak= you get the AK"></Script> <title>Location of Baidu Map</title></Head><Body> <DivID= "Allmap"style= "width:100%;height:500px;"></Div> <Scripttype= "Text/javascript"> //Baidu Map API features varMap= NewBmap.map ("Allmap"); var Point= NewBmap.point (108.95,34.27); Map.centerandzoom (Point, A); vargeolocation= Newbmap.geolocation (); Geolocation.getcurrentposition (function(R) {console.log (r.point)if( This. GetStatus ()==bmap_status_success) {varMk= NewBmap.marker (R.point); Map.addoverlay (MK);//mark the locationMap.panto (r.point);//Map Center Move //alert (' Your location: ' +r.point.lng+ ', ' +r.point.lat '); var Point= NewBmap.point (R.point.lng,r.point.lat);//find the location of the city streets and other information with the latitude and longitude of the location varGC= NewBmap.geocoder (); Gc.getlocation (Point,function(RS) {varAddcomp=rs.addresscomponents; Console.log (rs.address);//Address Informationalert (rs.address);//Popup Location}); }Else{alert ('failed'+ This. GetStatus ()); }},{enablehighaccuracy:true}) </Script></Body></HTML>
Get positioning, Apple IOS10 above does not support H5 geolocation get geo-location information solution