Browse Source

尝试获取精确地址

dev
巴林闲侠 2 years ago
parent
commit
4c0c0bb546
  1. 5
      weapp/src/packages/patrol/index.jsx

5
weapp/src/packages/patrol/index.jsx

@ -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

Loading…
Cancel
Save