/*
 * @Description: 高德地理逆编码
 * @Author: Fugang
 * @Date: 2019-09-11 11:12:08
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2021-06-24 14:13:49
 */
import axios from 'axios'
import { wgs84togcj02 } from '@/util/coordtransform.js'

var gaodeAddress = function (lnglat, callback) {
  let gaode = wgs84togcj02(lnglat[0], lnglat[1])
  let location = gaode[0] + ',' + gaode[1]
  let key = '0b03e4e031911ea59d23cacc749a09e4' // mudu
  axios
    .get(
      `https://restapi.amap.com/v3/geocode/regeo?location=${location}&key=${key}`
    )
    .then((res) => {
      callback(res)
    })
}

export { gaodeAddress }
