uniapp ios实行息屏传输实施地理信息

需求:uniapp开发原生ios,息屏之后将高德获取到的经纬度传输给后端

// ios实时定位
getIOSLocation (id) {
    
    
	var watchId = plus.geolocation.watchPosition( function ( res ) {
    
      
      // console.log( "监听位置变化信息:" );
       // console.log( res );
	let params = {
    
    
		"staffId": id, //(用户ID)
		"longitude": res.coords.longitude, //经度
		"latitude": res.coords.latitude //纬度
	}
	//这个是将拿到的信息传输给后端的接口请求
	this.$u.api.xxxx(params).then(result => {
    
    
		// console.log('定位请求成功')
	})
   }, function ( e ) {
    
      
       console.log( "监听位置变化信息失败:"+e.message );  
   }, {
    
    'enableHighAccuracy':true,'geocode': false} );
},

需要注意的: ios当进入这个方法的时候,会弹窗给提示,是否允许获取实时位置信息类似这种的弹窗,一定要点击循序,不然息屏是拿不到位置信息的

猜你喜欢

转载自blog.csdn.net/weixin_43877575/article/details/124384115