web解析同理
申请两个key:
Android平台:用于打包填写maps模块key
Web服务:用于逆向解析key(代码里要用,建议提取到项目config.js文件)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| handleNavigation(address) { const key = cfg.webGaoDeKey; uni.request({ url: `https://restapi.amap.com/v3/geocode/geo?address=${address}&key=${key}`, success(res) { if(res.data.status == 1){ const [longitude, latitude] = res.data.geocodes[0].location.split(",") console.log(longitude, "经度") console.log(latitude, "维度") uni.openLocation({ longitude: Number(longitude), latitude: Number(latitude), name: address, address: address, success(res) { console.log(res) }, fail(err){ console.log(err) } }) }else{ uni.showToast({ icon: "none", mask: true, title: res.data.info }) } } }) },
|