Taro.chooseLocation使用笔记

178 阅读1分钟

使用平台

支持在小程序和h5使用

相关配置

在config/index.js文件配置

  defineConstants: {
    LOCATION_APIKEY: JSON.stringify('xxx-xxxx-xxxx-xxxxx-xxxx-xxxx') // 这个JSON.stringify一定要有,不然后报错
  }

这个key需要申请 地址:开发者控制台

使用方法

Taro.chooseLocation({
    latitude, // 纬度
    longitude, // 经度
    mapOpts, // 地图选点组件参数
    title, // 页面显示标题
    success, // 接口调用成功的函数
    fail, // 接口调用失败的回调函数
    complete, // 接口调用结束的回调函数
})