欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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;
          }
	} );
}
相关标签: 啊啊

上一篇:

下一篇: