IOS11,定位签到功能不能够正常使用,抛出异常
经过测试验证,
不连接WIFI,使用IP进行定位,
在IOS11下程序才会抛出异常,其他操作系统移动端签到正常。
还请知道的朋友们指点一下
代码如下:
<script type="text/javascript">
/***************************************
由于Chrome、IOS10等已不再支持非安全域的浏览器定位请求,为保证定位成功率和精度,请尽快升级您的站点到HTTPS。
***************************************/
function geolocation(){
//加载地图,调用浏览器定位服务
var map = new AMap.Map('mapContainer', {
resizeEnable: true
});
map.plugin('AMap.Geolocation', function() {
var geolocation = new AMap.Geolocation({
enableHighAccuracy: true, // 是否使用高精度定位,默认:true
timeout: 60 * 1000, // 超过1分钟后停止定位,默认:无穷大
showButton: true, // 显示定位按钮
noIpLocate: 0, // 是否禁止使用IP定位,0: 可以使用IP定位;1: 手机设备禁止使用;2: PC禁止使用;3: 所有终端禁止使用
buttonOffset: new AMap.Pixel(10, 20), // 定位按钮与设置的停靠位置的偏移量,默认:Pixel(10, 20)
zoomToAccuracy: true, // 定位成功后调整地图视野范围使定位位置及精度范围视野内可见,默认:false
buttonPosition:'RB'
});
map.addControl(geolocation);
//返回定位信息
AMap.event.addListener(geolocation, 'complete', function(result) {
if(result.info == 'SUCCESS') {
map.setZoom(16);
//如为IP精确定位结果则没有精度信息
var info = result.formattedAddress;
if(result.accuracy) {
// info += '(精度:' + result.accuracy + '米)';
}
$('#location').html(info);
var position = result.position.getLng() + ',' + result.position.getLat();
$('[name=fdPlace]').val(info);
$('[name=fdLocation]').val(position);
}
});
//返回定位出错信息
AMap.event.addListener(geolocation, 'error', function(error) {
$('#location').html('定位失败:' + error.message);
$('[name=fdPlace]').val('');
$('[name=fdLocation]').val('');
});
geolocation.getCurrentPosition();
});
}
</script>