更新记录

1.0.1(2025-08-21)

  • 【优化】代码实现方式,提高准确率
  • 【修改】文档使用示例

1.0.0(2025-06-16)

  • 【新增】初始化第一版本
  • 【新增】申请权限,基础定位,停止定位,支持高度配置

平台兼容性

uni-app(4.66)

Vue2 Vue3 Chrome Safari app-vue app-vue插件版本 app-nvue app-nvue插件版本 Android Android插件版本 iOS 鸿蒙
- - - - 1.0.0 1.0.0 5.0 1.0.0 - -
微信小程序 支付宝小程序 抖音小程序 百度小程序 快手小程序 京东小程序 鸿蒙元服务 QQ小程序 飞书小程序 快应用-华为 快应用-联盟
- - - - - - - - - - -

uni-app x(4.66)

Chrome Safari Android Android插件版本 iOS 鸿蒙 微信小程序
- - 5.0 1.0.0 - - -

Turbo UI 系列插件 - 高德定位SDK

  • 如您已购买Turbo UI,那么该插件可以免费使用源码版!
  • 使用需要打自定义基座,最新支持4.71,4.66,4.63版本,其他自测
  • 支持单次定位,持续定位,场景定位,停止定位,销毁实例

配置

tALocationApi.setKey("你的key")

使用示例 - uni-app x 版本


<script setup lang="uts">
    import * as tALocationApi from "@/uni_modules/t-alocation-api"

    const getLocation = () => {
        tALocationApi.getLocation({
            once: true,
            needAddress: true,
            isWifiActiveScan: true,
            success: (result: tALocationApi.TALocationResult) => {
                console.log(result)
            },
            fail: (result: tALocationApi.TALocationResult) => {
                console.log(result)
            }
        } as tALocationApi.TALocationOptions)
    }
    const stopLocation = () => {
        tALocationApi.stopLocation({
            success: (result: tALocationApi.TALocationResult) => {
                console.log(result)
            },
            fail: (result: tALocationApi.TALocationResult) => {
                console.log(result)
            }
        } as tALocationApi.TALocationOptions)
    }

    const requestPermission = () => {
        tALocationApi.requestPermission({
            success: (result: tALocationApi.TALocationResult) => {
                console.log(result)
            },
            fail: (result: tALocationApi.TALocationResult) => {
                console.log(result)
            }
        } as tALocationApi.TALocationOptions)
    }
    onReady(() => {
        tALocationApi.updatePrivacyAgree(true)
        tALocationApi.updatePrivacyShow(true,true)
        tALocationApi.setKey("")
    })
</script>

暴露的类型

/**
 * @description 定位数据
 * @property {Number} latitude 纬度
 * @property {Number} longitude 经度
 * @property {String} address 地址信息
 * @property {String} country 国家
 * @property {String} province 省
 * @property {String} city 市
 * @property {String} district 区县
 * @property {String} street 街道
 * @property {Number} cityCode 城市编码
 * @property {Number} adCode 地区编码
 */
export type TALocationData = {
    latitude?: number;
    longitude?: number;
    address?: string;
    country?: string;
    province?: string;
    city?: string;
    district?: string;
    street?: string;
    adCode?: string;
    cityCode?: string;
}
/**
 * @description 返回
 * @property {Number} code 状态码
 * @property {String} msg 状态消息
 * @property {TALocationData} data 定位数据
 */
export type TALocationResult = {
    code: number;
    msg: string;
    data?: TALocationData
}
/**
 * @description 参数配置
 * @property {Number} locationMode 定位模式
 * @value 1 高精度
 * @value 2 低消耗
 * @value 3 仅设备
 * @property {Boolean} once 单次定位,不能与onceLatest同时使用
 * @property {Boolean} onceLatest 单次高精度定位,不能与once同时使用
 * @property {Number} interval 连续定位间隔时间,单位ms,默认2000
 * @property {Boolean} needAddress 是否返回地址描述,默认true
 * @property {Boolean} mockEnable 设置是否允许模拟位置,默认为true
 * @property {Boolean} httpTimeOut 设置定位请求超时时间,默认为30秒,单位ms
 * @property {Boolean} locationCacheEnable 设置是否开启定位缓存机制
 * @property {Boolean} isWifiActiveScan 是否会主动刷新设备wifi模块,获取到最新鲜的wifi列表(wifi新鲜程度决定定位精度);false表示不主动刷新。
 * @property {Number} protocol 用于设定网络定位时所采用的协议,提供http/https两种协议。
 * @value 1 HTTP
 * @value 2 HTTPS
 */
export type TALocationOptions = {
    locationMode?: number;
    once?: boolean;
    onceLatest?: boolean;
    interval?: number;
    needAddress?: boolean;
    mockEnable?: boolean;
    httpTimeOut?: boolean;
    locationCacheEnable?: boolean;
    isWifiActiveScan?: boolean;
    protocol?: number;
    success?: (result: TALocationResult) => void;
    fail?: (result: TALocationResult) => void;
}

隐私、权限声明

1. 本插件需要申请的系统权限列表:

权限参考:https://lbs.amap.com/api/android-location-sdk/guide/android-location/getlocation

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

插件使用的 高德定位 SDK会采集数据,详情可参考:https://lbs.amap.com/compliance-center/ability/data-security

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

暂无用户评论。