h5 plus 获取位置权限
程序员文章站
2023-12-28 09:09:40
...
function onPlusReady(){
plus.geolocation.getCurrentPosition(function(p){
console.log('Geolocation\nLatitude:' + p.coords.latitude + '\nLongitude:' + p.coords.longitude + '\nAltitude:' + p.coords.altitude);
}, function(e){
console.log('Gelocation Error: code - ' + e.code + '; message - ' + e.message);
switch(e.code) {
case e.PERMISSION_DENIED:
alert('User denied the request for Geolocation.');
break;
case e.POSITION_UNAVAILABLE:
alert('Location information is unavailable.');
break;
case e.TIMEOUT:
alert('The request to get user location timed out.');
break;
case e.UNKNOWN_ERROR:
alert('An unknown error occurred.');
break;
}
} );
}