const QQMapWX = require('./qqmap-wx-jssdk.min.js') // key: 'QNVBZ-FOQK3-ZOT3S-3GADS-7KAG3-LBBQB' //测即成key const qqmapsdk = new QQMapWX({ key: 'RXSBZ-GUOYJ-OZOFI-FBMOP-3CMF3-D6FGE' //hjt }) //逆向解析 function getNameByLatLng(latitude,longitude){ return new Promise((resolve,reject)=>{ qqmapsdk.reverseGeocoder({ location: {latitude,longitude}, success: res=> { // console.log("getNameByLatLng--",res.result) resolve(res.result); }, fail: err=> { reject("逆向地址解析错误"); console.log(err) } }) }) } async function chooseLoc(){ return new Promise(async (resolve,reject)=>{ let [cErr,cRes] = await uni.chooseLocation({type:'gcj02'}); if(cErr){ reject(cErr) return; } let {latitude,longitude} = cRes let loc = await getNameByLatLng(latitude,longitude) || {}; // console.log('getNameByLatLng===',loc); if( loc.address_component){ let {province,city,district} = loc.address_component; let {lat,lng} = loc.location; let desc = loc.formatted_addresses.recommend; resolve({ province, city, district, desc, latitude:lat, longitude:lng, }) return; } return reject(false); }) } export{ chooseLoc, }