uni.openLocation(OBJECT)

使用应用内置地图查看位置。 OBJECT 参数说明 示例

  1. uni.getLocation({ type: 'gcj02', //返回可以用于uni.openLocation的经纬度 success: function (res) { const latitude = res.latitude; const longitude = res.longitude; uni.openLocation({ latitude: latitude, longitude: longitude, success: function () { console.log('success'); } }); }});

Tips

  • https 服务上,本地预览(localhost)仍然可以使用 http 协议。
  • <map> 组件默认为国测局坐标,调用 uni.getLocation 返回结果传递给 <map> 组件时,需指定 type 为 gcj02。
  • urlschemewhitelist 节点,在线打包即可
    1. { "app-plus": { "distribute": { "ios": { "urlschemewhitelist": [ "baidumap", "iosamap", "qqmap" ] } } } }
  • fail 回调中

在 GitHub 上编辑此页面!