更新记录
1.0.0(2025-12-23)
下载此版本
鸿蒙花瓣地图
平台兼容性
uni-app(4.62)
| Vue2 |
Vue3 |
Chrome |
Safari |
app-vue |
app-nvue |
Android |
iOS |
鸿蒙 |
| - |
- |
× |
× |
× |
× |
× |
× |
12 |
| 微信小程序 |
支付宝小程序 |
抖音小程序 |
百度小程序 |
快手小程序 |
京东小程序 |
鸿蒙元服务 |
QQ小程序 |
飞书小程序 |
快应用-华为 |
快应用-联盟 |
| × |
× |
× |
× |
× |
× |
× |
× |
× |
× |
× |
uni-app x(4.62)
| Chrome |
Safari |
Android |
iOS |
鸿蒙 |
微信小程序 |
| × |
× |
× |
× |
12 |
× |
cr-uts-map 鸿蒙原生花瓣地图
快速使用
鸿蒙应用可免费使用鸿蒙系统提供的地图服务
开通方式:
- 登录 AGC 后台 选择开发与服务 - 选择应用 - 项目设置 - API 管理 - 开启地图服务
参考文档:
使用示例
<!-- 在 template 中使用, tag属性固定写 crmap -->
<embed class="map-container" tag="crmap" :options="mapOptions" @mapload="handleMapLoad"></embed>
// #ifdef APP-HARMONY
import type {
IMapBuilderOptions,
IMapEvent,
IMapInstance,
} from "@/uni_modules/cr-uts-map";
import { mapInstanceSet } from "@/uni_modules/cr-uts-map";
// #endif
// #ifdef APP-HARMONY
// 地图实例
let mapInstance: IMapInstance | null = null;
/**
* 地图组件参数
*/
const mapOptions: IMapBuilderOptions = {
mapType: "STANDARD",
dayNightMode: "AUTO",
zoom: 10,
minZoom: 2,
maxZoom: 20,
latitude: 39.909189,
longitude: 116.397454,
};
/**
* 地图组件初始化完成
*/
async function handleMapLoad(e: IMapEvent) {
mapInstance = mapInstanceSet[e.detail.mapId];
if (!(mapInstance && mapInstance.mapController)) {
return;
}
// mapController 具体使用方式可参考:https://developer.huawei.com/consumer/cn/doc/harmonyos-references/map-map-mapcomponentcontroller
const { mapController } = mapInstance;
mapController.setScaleControlsEnabled(true);
// 加载热区:https://developer.huawei.com/consumer/cn/doc/harmonyos-references/map-common#section1615694815308
const polygon = {
points: [
{ latitude: 41.893478, longitude: 116.4 },
{ latitude: 41.893478, longitude: 121.4 },
{ latitude: 45.893478, longitude: 121.4 },
{ latitude: 45.893478, longitude: 116.4 }
],
holes: [],
}
const mapPolygon = await mapController.addPolygon(polygon)
}
// #endif
参数配置
在 Vue 文件中使用的 embed 组件是经过 uni-app 封装的,更便于使用,支持传递额外的属性和事件。
| 属性名 |
类型 |
说明 |
| mapId |
mapId |
地图 id |
| longitude |
number |
中心经度 |
| latitude |
number |
中心纬度 |
| zoom |
number |
缩放级别 |
| minZoom |
number |
最小缩放级别 |
| maxZoom |
number |
最大缩放级别 |
| mapType |
string |
地图类型(STANDARD: 标准地图,NONE: 空地图,TERRAIN: 地形图,SATELLITE: 卫星图(6.0.0 及更高版本),HYBRID: 混合地图 (6.0.0 及更高版本)) |
| dayNightMode |
string |
显示模式(DAY: 日间模式,NIGHT: 夜间模式,AUTO:自动模式) |
| showMyLocation |
boolean |
显示我的定位 |
| width |
number |
宽度 |
| height |
number |
高度 |
回调方法
| 属性名 |
说明 |
| @mapload |
地图组件初始化完成 |
注意事项