文档管理中心

Interface (BasePriorityOverlay)

Phone5.0.0(12)+PC/2in15.0.1(13)+Tablet5.0.0(12)+Wearable5.1.0(18)+

导入模块

import { map, mapCommon } from '@kit.MapKit';

BasePriorityOverlay

Phone5.0.0(12)+PC/2in15.0.1(13)+Tablet5.0.0(12)+Wearable5.1.0(18)+

具有优先级控制的覆盖物基础类,继承BaseOverlayPointAnnotationBubble继承该基础类。

模型约束: 此接口仅可在Stage模型下使用。

元服务API: 从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力: SystemCapability.Map.Core

起始版本: 4.1.0(11)

getMaxZoom

Phone5.0.0(12)+PC/2in15.0.1(13)+Tablet5.0.0(12)+Wearable5.1.0(18)+

getMaxZoom(): number

获取覆盖物的最大展示层级。

模型约束: 此接口仅可在Stage模型下使用。

元服务API: 从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力: SystemCapability.Map.Core

起始版本: 4.1.0(11)

返回值:

展开
类型 说明
number 覆盖物的最大展示层级。

示例:

// 以pointAnnotation为例
let pointAnnotationOptions: mapCommon.PointAnnotationParams = {
  position: {
    latitude: 32.120750,
    longitude: 118.788765
  },
  titles: [{
    content: "南京夫子庙"
  }],
  // 图标需存放在resources/rawfile目录下
  icon: 'icon.png'
};
let pointAnnotation: map.PointAnnotation = await this.mapController.addPointAnnotation(pointAnnotationOptions);
let maxZoom: number = pointAnnotation.getMaxZoom();

getMinZoom

Phone5.0.0(12)+PC/2in15.0.1(13)+Tablet5.0.0(12)+Wearable5.1.0(18)+

getMinZoom(): number

获取覆盖物的最小展示层级。

模型约束: 此接口仅可在Stage模型下使用。

元服务API: 从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力: SystemCapability.Map.Core

起始版本: 4.1.0(11)

返回值:

展开
类型 说明
number 覆盖物的最小展示层级。

示例:

// 以pointAnnotation为例
let minZoom: number = pointAnnotation.getMinZoom();

setPriority

Phone5.0.0(12)+PC/2in15.0.1(13)+Tablet5.0.0(12)+Wearable5.1.0(18)+

setPriority(priority: number): void

设置覆盖物碰撞优先级,值越大优先级越低。

模型约束: 此接口仅可在Stage模型下使用。

元服务API: 从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力: SystemCapability.Map.Core

起始版本: 4.1.0(11)

参数:

展开
参数名 类型 必填 说明
priority number 覆盖物的碰撞优先级,值越大优先级越低。

示例:

// 以pointAnnotation为例
pointAnnotation.setPriority(100);

setZoom

Phone5.0.0(12)+PC/2in15.0.1(13)+Tablet5.0.0(12)+Wearable5.1.0(18)+

setZoom(minZoom: number, maxZoom: number): void

设置覆盖物的显示层级。

模型约束: 此接口仅可在Stage模型下使用。

元服务API: 从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力: SystemCapability.Map.Core

起始版本: 4.1.0(11)

参数:

展开
参数名 类型 必填 说明
minZoom number

覆盖物的最小显示层级,取值范围:[2, 20]。

传入的值高于20,最小缩放级别会取20。

传入的值小于2,最小缩放级别会取2。

说明:

minZoom大于maxZoom,方法不生效。

maxZoom number

覆盖物的最大显示层级,取值范围:[2, 20]。

传入的值高于20,最大缩放级别会取20。

传入的值小于2,最大缩放级别会取2。

示例:

// 以pointAnnotation为例
pointAnnotation.setZoom(3, 10);

setAnimation

Phone5.0.0(12)+PC/2in15.0.1(13)+Tablet5.0.0(12)+Wearable5.1.0(18)+

setAnimation(animation: Animation): void

设置覆盖物的动画。仅支持AlphaAnimationScaleAnimationAnimationSet

模型约束: 此接口仅可在Stage模型下使用。

元服务API: 从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力: SystemCapability.Map.Core

起始版本: 4.1.0(11)

参数:

展开
参数名 类型 必填 说明
animation Animation 动画。

示例:

// 创建一个透明度动画,从0.2到1
let animation: map.AlphaAnimation = new map.AlphaAnimation(0.2, 1);
// 设置动画持续时间为3000毫秒
animation.setDuration(3000);
// 定义动画开始时的回调函数
let callbackStart = () => {
  console.info("animationStart", `callback`);
};
// 定义动画结束时的回调函数
let callbackEnd = () => {
  console.info("animationEnd", `callback`);
};
// 注册动画开始事件监听器
animation.on("animationStart", callbackStart);
// 注册动画结束事件监听器
animation.on("animationEnd", callbackEnd);
// 设置动画填充模式为BACKWARDS,表示动画结束后回到初始状态
animation.setFillMode(map.AnimationFillMode.BACKWARDS);
// 设置动画重复模式为RESTART,表示每次重复从头开始
animation.setRepeatMode(map.AnimationRepeatMode.RESTART);
// 设置动画重复次数为100次
animation.setRepeatCount(100);
// 将动画应用到点注释上
pointAnnotation.setAnimation(animation);

startAnimation

Phone5.0.0(12)+PC/2in15.0.1(13)+Tablet5.0.0(12)+Wearable5.1.0(18)+

startAnimation(): void

启动覆盖物的动画。

模型约束: 此接口仅可在Stage模型下使用。

元服务API: 从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力: SystemCapability.Map.Core

起始版本: 4.1.0(11)

示例:

// 创建一个透明度动画,从0.2到1
let animation: map.AlphaAnimation = new map.AlphaAnimation(0.2, 1);
// 设置动画持续时间为3000毫秒
animation.setDuration(3000);
// 定义动画开始时的回调函数
let callbackStart = () => {
  console.info("animationStart", `callback`);
};
// 定义动画结束时的回调函数
let callbackEnd = () => {
  console.info("animationEnd", `callback`);
};
// 注册动画开始事件监听器
animation.on("animationStart", callbackStart);
// 注册动画结束事件监听器
animation.on("animationEnd", callbackEnd);
// 设置动画填充模式为BACKWARDS,表示动画结束后回到初始状态
animation.setFillMode(map.AnimationFillMode.BACKWARDS);
// 设置动画重复模式为RESTART,表示每次重复从头开始
animation.setRepeatMode(map.AnimationRepeatMode.RESTART);
// 设置动画重复次数为100次
animation.setRepeatCount(100);
// 将动画应用到点注释上
pointAnnotation.setAnimation(animation);
// 启动动画
pointAnnotation.startAnimation();

clearAnimation

Phone5.0.0(12)+PC/2in15.0.1(13)+Tablet5.0.0(12)+Wearable5.1.0(18)+

clearAnimation(): void

清除覆盖物的动画。

模型约束: 此接口仅可在Stage模型下使用。

元服务API: 从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力: SystemCapability.Map.Core

起始版本: 4.1.0(11)

示例:

pointAnnotation.clearAnimation();
在 开发与测试 开放能力API 中进行搜索
请输入您想要搜索的关键词