5***@qq.com
5***@qq.com
  • 发布:2024-07-03 15:55
  • 更新:2024-09-08 12:39
  • 阅读:115

监听实时定位plus.geolocation.watchPosition方法无法关闭,调用 clearWatch()方法也没用

分类:HTML5+
                                         var _this = this  
                     _this.watchId = plus.geolocation.watchPosition(function(position) {  
                        let coords = position.coords;  
                        let address = position.addresses  
                        console.log("获取经纬度信息:", coords.longitude, coords.latitude)  
                        console.log("获取地址信息:", address)  
                        // console.log("返回id" ,plus.geolocation.watchPosition());  
                        _this.checkAdress(coords.latitude, coords.longitude)  
                        _this.longitude = coords.longitude;  
                        _this.latitude = coords.latitude;  
                        _this.dataForm.punchSite = coords.longitude + ',' + coords.latitude  
                        //标记点赋值  
                        _this.markers[0].longitude = coords.longitude;  
                        _this.markers[0].latitude = coords.latitude;  
                        //获取当前当前位置的名称  
                        _this.locationcourier = address;  
                        _this.dataForm.punchSiteName = _this.locationcourier  
                    }, function(e) {  
                        console.log("监听位置变化信息失败:" + e.message);  
                    }, {  
                        'enableHighAccuracy': true,  
                        'geocode': true,  
                        'provider': 'amap',  
                        // 'maximumAge': 3000  
                    });

获取的watchId 不是number 而是个类似于'timer13213123'的字符串,无法,怎么关都关不掉,哪怕退出后台都还在获取地址,打印plus.geolocation.clearWatch() 发现是个undefined ,我人都傻了,这个h5+到底是啥意思,不能用的东西放上来干啥 ,全是bug,有没有大佬遇到过的,给点建议

0 关注 分享

要回复文章请先登录注册

强哥2023

强哥2023

怎么解决得??
2024-09-08 12:39