Get positioning, Apple IOS10 above does not support H5 geolocation get geo-location information solution

Source: Internet
Author: User

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

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.