uni-app 打开内置地图(十三)

uni.openLocation(OBJECT)

使用应用内置地图查看位置。

OBJECT 参数说明

参数名 类型 必填 说明
latitude Float 纬度,范围为-90~90,负数表示南纬
longitude Float 经度,范围为-180~180,负数表示西经
scale INT 缩放比例,范围5~18,默认为18
name String 位置名
address String 地址的详细说明
success Function 接口调用成功的回调函数
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

示例

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');
            }
        });
    }
});

官网原文地址 

发布了117 篇原创文章 · 获赞 446 · 访问量 62万+

猜你喜欢

转载自blog.csdn.net/zhuoganliwanjin/article/details/81974119