高德地圖開放平台:https://lbs.amap.com/faq/js-api/map-js-api/position-related/46320
訪問https://a.amap.com/jsapi_demos/static/remogeo/remo.html
查看源碼如下:
// ios環境切換到使用遠程https定位 if (AMap.UA.ios && document.location.protocol !== 'https:') { //使用遠程定位,見 remogeo.js var remoGeo = new RemoGeoLocation(); //替換方法 navigator.geolocation.getCurrentPosition = function() { return remoGeo.getCurrentPosition.apply(remoGeo, arguments); }; //替換方法 navigator.geolocation.watchPosition = function() { return remoGeo.watchPosition.apply(remoGeo, arguments); }; }
實際使用中要加上document.location.protocol !== 'https:'這個條件,但官網給出的解決方案中沒有這句