1 uni.getLocation({ 2 type: 'wgs84', 3 success: function(res) { 4 console.log('当前位置的经度:' + res.longitude); 5 console.log('当前位置的纬度:' + res.latitude); 6 var point = new plus.maps.Point(res.longitude, res.latitude); 7 plus.maps.Map.reverseGeocode( 8 point, 9 {},10 function(event) {11 var address = event.address; // 转换后的地理位置12 var point = event.coord; // 转换后的坐标信息13 var coordType = event.coordType; // 转换后的坐标系类型14 console.log(address, 'address');15 },16 function(e) {}17 );18 }19 });
uni.getLocation({ type: 'wgs84', success: function(res) { console.log('当前位置的经度:' + res.longitude); console.log('当前位置的纬度:' + res.latitude); var point = new plus.maps.Point(res.longitude, res.latitude); plus.maps.Map.reverseGeocode( point, {}, function(event) { var address = event.address; // 转换后的地理位置 var point = event.coord; // 转换后的坐标信息 var coordType = event.coordType; // 转换后的坐标系类型 console.log(address, 'address'); var reg = /.+?(省|市|自治区|自治州|县|区)/g; console.log(address.match(reg)); _this.addressList=address.match(reg).toString().split(","); _this.address= _this.addressList[1]; console.log(_this.addressList[0]); console.log(_this.addressList[1]); console.log(_this.addressList[2]); }, function(e) {} ); } });