npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@cordova-ohos/cordova-plugin-baidumaplocation

v4.0.2

Published

Cordova baidumaplocation Plugin

Downloads

145

Readme

cordova-plugin-baidumaplocation 百度地图定位插件

一款基于百度地图定位SDK开发的 Cordova 定位插件,为混合式移动应用提供高精度、高稳定性的地理位置获取服务,支持GPS、网络、基站等多源定位方式,适配 Android 、 iOS和OHOS 三平台,满足各类场景下的定位需求。

该插件在OHOS系统平台上,不直接应用Baidu地图,而是使用OHOS原生定位功能定位,然后转为baidu地图的坐标。

功能特性

  • 多源定位:支持 GPS、Wi-Fi、基站、蓝牙等多种定位方式,自动根据场景选择最优定位源

  • 高精度定位:GPS 定位精度可达米级,网络定位精度可达百米级,满足不同精度需求

  • 持续定位:支持单次定位和持续定位两种模式,持续定位可自定义定位间隔

  • 逆地理编码:支持将经纬度坐标转换为详细地址信息(省、市、区、街道、门牌号等)

  • 定位监听:提供定位成功、失败、权限变更等事件监听,便于业务逻辑处理

  • 权限管理:自动处理定位权限申请,支持权限状态查询和手动申请

  • 低功耗模式:持续定位时支持低功耗模式,减少设备电量消耗

安装方法

1. 基础安装(指定 API Key)


# 安装hcordova
npm install -g hcordova

# OHOS系统安装
hcordova plugin add cordova-plugin-baidumaplocation --platform ohos

2. 安装指定版本


# 安装 1.0.0 版本(示例)
hcordova plugin add [email protected] --platform ohos

3. 从 GitCode 安装开发版


hcordova plugin add https://gitcode.com/OpenHarmony-Cordova/cordova-plugin-baidumaplocation.git --platform ohos

卸载方法

进入项目根目录,执行以下命令卸载插件:

# 全平台卸载
hcordova plugin remove cordova-plugin-baidumaplocation

# 指定OHOS卸载
hcordova plugin remove cordova-plugin-baidumaplocation --platform ohos

平台配置

插件安装后需根据目标平台进行必要配置,确保定位功能正常运行。

OHOS 配置

使用该插件需要配置获取地理位置权限,否则无法定位

"requestPermissions": [
    {
    "name" : "ohos.permission.LOCATION",
    "reason": "$string:locationInfo", 
    "usedScene": {
        "abilities": [
        "EntryAbility"
        ],
        "when": "always"
    }
    },
    {
    "name" : "ohos.permission.APPROXIMATELY_LOCATION",
    "reason": "$string:locationInfo",
    "usedScene": {
        "abilities": [
        "EntryAbility"
        ],
        "when": "always"
    }
    },
    {
    "name" : "ohos.permission.LOCATION_IN_BACKGROUND",
    "reason": "$string:locationInfo",
    "usedScene": {
        "abilities": [
        "EntryAbility"
        ],
        "when": "always"
    }
    }
]

权限配置

核心 API

插件通过全局对象 cordova.plugins.baidumaplocation 暴露所有接口,所有方法均为异步执行,通过成功回调和错误回调处理结果。

检查应用是否已获取定位权限。

/*
* time: 时间戳
* locType: 1:GNSS,2:NETWORK,3:INDOOR,4:RTK
* locTypeDescription:GNSS,NETWORK,INDOOR,RTK
* latitude:纬度
* longitude:经度
* altitude:海拔
* radius:精度
* country:国家
* city:城市
* district:区县
* street:街道
* addr:地址
* province:省份
* userIndoorState:室内状态
* direction:方向
* locationDescribe:位置描述
*/
baidumap_location.getCurrentPosition(function (result) {
    document.getElementById("localInfo").innerHTML = JSON.stringify(result);
    console.log(JSON.stringify(result));
}, function (error) {

});

许可证

本插件采用 **[Apache License 2.0]**详见 LICENSE 文件。

联系方式