应要求增加了高德地图定位来获取当前位置的经纬度,在公司连网没问题,连手机热点或者在家都获取不到,哪位大神可以帮忙看一下
var map, geolocation;
//加载地图,调用浏览器定位服务 高德地图
map = new AMap.Map('container', {
resizeEnable: true
});
map.plugin('AMap.Geolocation', function() {
geolocation = new AMap.Geolocation({
enableHighAccuracy: true, //是否使用高精度定位,默认:true
timeout: 10000, //超过10秒后停止定位,默认:无穷大
buttonPosition: 'RB'
});
map.addControl(geolocation);
geolocation.getCurrentPosition();
console.log(geolocation)
AMap.event.addListener(geolocation, 'complete', function onComplete(data) {
var getLatitude = data.position.getLng();
var getLongitude = data.position.getLat();
console.log(getLongitude,getLongitude)
sessionStorage.setItem('latitude',getLatitude);
sessionStorage.setItem('longitude',getLongitude);
}); //返回定位信息