In iOS 10, Apple has modified the WebKit location permission, and all location-requested pages must be HTTPS protocol.
If a non-HTTPS Web page, the HTTP protocol through the HTML5 native location interface will return an error, that is, unable to properly navigate to the user's specific location, and the Web site that has supported HTTPS will not be affected.
The solutions currently available:
1. Set HTTP for the website to HTTPS.
2, through the third-party API solution.
By the way the location method is attached:
//// positioning method One
$ (function () {
Startgps ();
});
//Get Geolocation method
function Startgps ()
{
//Determine if support is supported
if (navigator.geolocation)
{
navigator.geolocation.getCurrentPosition (showgps,//success callback function
function (Error)//failure callback
{
Getpositionerror (error);
},
{enablehighacuracy:true, timeout:5000,maximumage:0}); This sets the timeout to 5000 milliseconds, or 1 seconds.
}
Else
{
document.getElementById (' Geo_loc '). innerhtml= "Your browser does not support map positioning";
}
}
function Showgps (position)
{
document.getElementById (' longitude '). Innerhtml= "Longitude" +position.coords.longitude+ "latitude" +position.coords.latitu De;
getaddress (position.coords.latitude,position.coords.longitude);
}
function Getpositionerror (error) {
switch (error.code) {
Case error. TIMEOUT:
alert ("Connection timed out, please retry");
Break ;
Case error. Permission_denied:
alert ("You refused to use Location sharing service, query cancelled");
Break ;
Case error. Position_unavailable:
alert ("Dear Mars netizen, very sorry, we are temporarily unable to provide location services for your planet");
Break ;
}
}
//Positioning method two
if (navigator.geolocation) {
Navigator.geolocation.getCurrentPosition (
function (position) {
document.getElementById (' longitude '). Innerhtml= "Longitude" +position.coords.longitude+ "latitude" +position.coord S.latitude;
document.getElementById (' accuracy '). Innerhtml= "Error" +position.coords.accuracy+ "M";
getaddress (position.coords.latitude,position.coords.longitude);
},
function (Error) {
var errorType = [' You refuse to share location information ', ' Get location information ', ' Get location information timed out '];
//alert (errortype[error.code-1]);
document.getElementById (' Geo_loc '). innerhtml=error.code+ "\ n" +error.message;
document.getElementById (' Geo_loc '). innerhtml= errortype[error.code-1];
}
);
}else{
document.getElementById (' Geo_loc '). innerhtml= "Your browser does not support map positioning";
}
function GetAddress (latitude,longitude) {
var Geocoder;
var map = new Amap.map ("container", {
Resizeenable:true,
zoom:18
})
var lnglatxy = [longitude,latitude];//the coordinates to be converted to address description
//Loading geocoding plugins
var Geocoder;
Amap.service (["Amap.geocoder"], function () {
Geocoder = new Amap.geocoder ({
radius:1000,
extensions: "All"
});
//Inverse geo-coding
geocoder.getaddress (Lnglatxy, function (status, result) {
//Retrieving Inverse geocoding results
if (status = = = ' complete ' && result.info = = = ' OK ') {
geocoder_callback (result);
}
});
});
}
function Geocoder_callback (data) {
var address = data.regeocode.formattedAddress;//Return addresses description
document.getElementById ("result"). InnerHTML = Address;
}
IOS10 Window.navigator.geolocation.getCurrentPosition cannot locate the problem