|
|
@ -157,16 +157,19 @@ const Index = () => { |
|
|
|
Taro.showLoading({ title: '加载中' }) |
|
|
|
let key = 'ODQBZ-3FZAU-6VIVL-2XXNM-F7CP7-WVFCY' // 写自己申请的key |
|
|
|
Taro.getLocation({ |
|
|
|
type: 'wgs84', |
|
|
|
// type: 'wgs84', |
|
|
|
type: 'gcj02', |
|
|
|
isHighAccuracy: true, |
|
|
|
highAccuracyExpireTime: 1000 * 6, |
|
|
|
success: function (res) { |
|
|
|
console.log(res); |
|
|
|
setLongitude(res.longitude) |
|
|
|
setLatitude(res.latitude) |
|
|
|
Taro.request({ |
|
|
|
url: `https://apis.map.qq.com/ws/geocoder/v1/?location=${res.latitude},${res.longitude}&key=${key}`, |
|
|
|
success: function (res) { |
|
|
|
// 根据自己项目需求获取res内容 |
|
|
|
console.log('地址信息:', res); |
|
|
|
let addresscity = '' |
|
|
|
addresscity = |
|
|
|
res.data.result.address_component.province |
|
|
|