We use essential cookies for the website to function, as well as analytics cookies for analyzing and creating statistics of the website performance. To agree to the use of analytics cookies, click "Accept All". You can manage your preferences at any time by clicking "Cookie Settings" on the footer. More Information.

Only Essential Cookies
Accept All
MaterialsConsole

Interface (PointAnnotation)

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

Modules to Import

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

PointAnnotation

PointAnnotation. This API inherits from BasePriorityOverlay. An instance of this type will be returned when the addPointAnnotation method in the map.MapComponentController class is called.

Model restriction: This API can be used only in the stage model.

Atomic service API: This API can be used in atomic services since version 4.1.0(11).

System capability: SystemCapability.Map.Core

Since: 4.1.0(11)

Example:

let pointAnnotationOptions: mapCommon.PointAnnotationParams = {
  position: {
    latitude: 32.120750,
    longitude: 118.788765
  },
  titles: [{
    content: "Nanjing Confucius Temple"
  }],
  // The icon must be stored in the resources/rawfile directory.
  icon: 'icon.png'
};
let pointAnnotation: map.PointAnnotation = await this.mapController.addPointAnnotation(pointAnnotationOptions);

getPosition

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

getPosition(): mapCommon.LatLng

Obtains the anchor coordinates of a PointAnnotation.

Model restriction: This API can be used only in the stage model.

Atomic service API: This API can be used in atomic services since version 4.1.0(11).

System capability: SystemCapability.Map.Core

Since: 4.1.0(11)

Returns:

Expand
Type Description
mapCommon.LatLng Anchor coordinates of a PointAnnotation.

Example:

let position: mapCommon.LatLng = pointAnnotation.getPosition();

getTitleText

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

getTitleText(): mapCommon.Text

Obtains the attributes of a PointAnnotation's first title.

Model restriction: This API can be used only in the stage model.

Atomic service API: This API can be used in atomic services since version 4.1.0(11).

System capability: SystemCapability.Map.Core

Since: 4.1.0(11)

Returns:

Expand
Type Description
mapCommon.Text Attributes of a PointAnnotation's first title.

Example:

let titleText: mapCommon.Text = pointAnnotation.getTitleText();

setTitleText

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

setTitleText(text: mapCommon.Text): void

Sets the attributes of a PointAnnotation's first title (content excluded).

Model restriction: This API can be used only in the stage model.

Atomic service API: This API can be used in atomic services since version 4.1.0(11).

System capability: SystemCapability.Map.Core

Since: 4.1.0(11)

Parameters:

Expand
Name Type Mandatory Description
text mapCommon.Text Yes

Attributes of a PointAnnotation's first title (content excluded). Invalid values are not processed.

Note:

Constraints: The values of fontSize and strokeWidth must be greater than or equal to 0.

Example:

// Use a PointAnnotation as an example.
pointAnnotation.setTitleText({
  content: '',
  color: 0xff00ffff,
  fontSize: 15,
  strokeColor: 0xff00ff00,
  strokeWidth: 2,
  fontStyle: mapCommon.FontStyle.BOLD_ITALIC
});

setTitleAnimation

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

setTitleAnimation(animation: FontSizeAnimation): void

Sets the title animation of a PointAnnotation.

Model restriction: This API can be used only in the stage model.

Atomic service API: This API can be used in atomic services since version 4.1.0(11).

System capability: SystemCapability.Map.Core

Since: 4.1.0(11)

Parameters:

Expand
Name Type Mandatory Description
animation FontSizeAnimation Yes Title animation of a PointAnnotation.

Example:

let animation: map.FontSizeAnimation = new map.FontSizeAnimation(5, 25);
animation.setDuration(3000);
animation.on("start", () => {
  console.info('start Font Animation');
});
animation.on("end", () => {
  console.info('end Font Animation');
});
// Set the status after the animation ends.
animation.setFillMode(map.AnimationFillMode.BACKWARDS);
// Set the animation replay mode.
animation.setRepeatMode(map.AnimationRepeatMode.REVERSE);
// Set an animation interpolator.
animation.setInterpolator(Curve.Linear);
// Set the number of times the animation is replayed.
animation.setRepeatCount(100);
pointAnnotation.setTitleAnimation(animation);
pointAnnotation.startTitleAnimation();

startTitleAnimation

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

startTitleAnimation(): void

Starts the title animation of a PointAnnotation.

Model restriction: This API can be used only in the stage model.

Atomic service API: This API can be used in atomic services since version 4.1.0(11).

System capability: SystemCapability.Map.Core

Since: 4.1.0(11)

Example:

pointAnnotation.startTitleAnimation();