h5 plus 获取位置权限

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;
          }
	} );
}

猜你喜欢

转载自blog.csdn.net/weixin_38641550/article/details/81066145
今日推荐