产品服务
解决方案
文档与支持
定价
工程配置与SDK集成
下载开发文档
Har包配置
1.命令行方式

可通过OpenHarmony三方库中心仓查看百度地图提供的三方库列表以及版本更新情况。 安装过程可采用下面两种方式中的任意一种。 一种是通过命令安装指定版本的三方库, package_name 换成安装的库名, version 换成对应的版本

ohpm install @bdmap/navi_map@<version>
2.配置文件方式
通过配置文件,触发IDE 的 Sync Now拉取三方库。 在工程的oh-package.json5文件中添加依赖。配置如下:
{
"license": "Apache License 2.0",
"devDependencies": {},
"name": "entry",
"description": "example description",
"version": "1.0.1",
"dependencies": {
//添加依赖如下
"@bdmap/navi_map": "1.0.0",
}
}
权限配置

需要在module.json5中配置相关权限,分为5个部分:网络相关,定位相关,导航相关,APP信息相关,传感器相关, 特别需要注意:需要配置backgroundModes支持location,audioPlayback,否则退到后台,定位和播报停止工作。可参考下面配置:

{
"module": {
"name": "xxx",
"type": "xxx",
"description": "xxx",
"mainElement": "xxx",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": xxx,
"installationFree": xxx,
"pages": "xxx",
"abilities": [
{
"name": "xxx",
"srcEntry": "xxx",
"description": "xxx",
"icon": "xxx",
"label": "xxx",
"startWindowIcon": "xxx",
"startWindowBackground": "xxx",
"exported": xxx,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"backgroundModes": [
"location", "audioPlayback"
]
}
],
"requestPermissions": [
{
"name": "ohos.permission.INTERNET",
"reason": "$string:Request_for_INTERNET_permission_desc",
"usedScene": {
"abilities": [
"xxx"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.GET_BUNDLE_INFO",
"reason": "$string:Request_for_GET_BUNDLE_INFO_permission_desc",
"usedScene": {
"abilities": [
"xxx"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.LOCATION",
"reason": "$string:Request_for_LOCATION_permission_desc",
"usedScene": {
"abilities": [
"xxx"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.LOCATION_IN_BACKGROUND",
"reason": "$string:Request_for_LOCATION_IN_BACKGROUND_permission_desc",
"usedScene": {
"abilities": [
"xxx"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.APPROXIMATELY_LOCATION",
"reason": "$string:Request_for_APPROXIMATELY_LOCATION_permission_desc",
"usedScene": {
"abilities": [
"xxx"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.APP_TRACKING_CONSENT",
"reason": "$string:Request_for_APP_TRACKING_CONSENT_permission_desc",
"usedScene": {
"abilities": [
"xxx"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.GET_WIFI_INFO",
"reason": "$string:Request_for_GET_WIFI_INFO_permission_desc",
"usedScene": {
"abilities": [
"xxx"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.GET_NETWORK_INFO",
"reason": "$string:Request_for_GET_NETWORK_INFO_permission_desc",
"usedScene": {
"abilities": [
"xxx"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.KEEP_BACKGROUND_RUNNING",
"reason": "$string:Request_for_KEEP_BACKGROUND_RUNNING_permission_desc",
"usedScene": {
"abilities": [
"xxx"
],
"when": "inuse"
}
},
{ "name": "ohos.permission.ACCELEROMETER" },
{
"name": "ohos.permission.ACCESS_CAR_DISTRIBUTED_ENGINE"
},
{
"name": "ohos.permission.ACCESS_SERVICE_NAVIGATION_INFO"
}
],
}
}
开发者注意事项

最低版本支持API12。

上一篇

注册和获取密钥

下一篇

基础功能

本篇文章对您是否有帮助?