详见:码云小程序demo1
1.注册腾讯地图
>设置key
>key管理勾选WebServiceAPI
2.开发文档
>服务端WebServiceAPI
>逆地址解析(坐标位置描述)
3.wxml
<van
-cell
-group
>
  {{address
}}
  <!-- autosize
:自适应 
-->
  <van
-field autosize type
="textarea"
   model
:value
="{{ address }}" center clearable label
="短信验证码"
    placeholder
="请输入短信验证码"
    border
="{{ false }}" use
-button
-slot
>
    <van
-button custom
-style
="width:100rpx" slot
="button"
     size
="small" type
="primary" icon
="location-o"
      bindtap
="getAddress3"></van
-button
>
  </van
-field
>
</van
-cell
-group
>
3.js
import Router 
from '../../utils/index'
import {
  getLocationWithSetting
} from '../../utils/location'
Router({
  
  data
: {
    address
: '',
  },
  async getAddress3() { 
    let res 
= await getLocationWithSetting()
    console
.log(res
);
    if (res
) {
      let address 
= await this.$
get('https://apis.map.qq.com/ws/geocoder/v1/', { 
      
        location
: [res
.lat
, res
.lng
].join(),
        key
: 'K2VBZ-IM5WO-V65W7-SV4SA-W4HYF-VSFD3'
      }
     
      this.$
set('address', address
.result
.address 
+ 
      address
.result
.formatted_addresses
.recommend
)
    }
  },
}
                
                
                
        
    
转载请注明原文地址:https://tech.qufami.com/read-19382.html