Intelligent Assistant
Chat with our virtual assistant to get answers promptly.
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.
HarmonyOS
- import { map, mapCommon } from '@kit.MapKit';
MapPolygon. This API inherits from BaseOverlay. A MapPolygon can be convex or concave. It can span the 180th meridian and have holes that are not filled in. An instance of this type will be returned when the addPolygon 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 polygonOptions: mapCommon.MapPolygonOptions = {
- points: [
- { latitude: 31.9844102, longitude: 118.7662 },
- { latitude: 31.9844102, longitude: 123.7662 },
- { latitude: 36.9844102, longitude: 123.7662 },
- { latitude: 36.9844102, longitude: 118.7662 }
- ],
- fillColor: 0xffff4500
- };
- let mapPolygon = await this.mapController.addPolygon(polygonOptions);
getFillColor(): number
Obtains the fill color of a MapPolygon, in ARGB format.
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:
| Type | Description |
|---|---|
| number | Color in ARGB format. |
Example:
- let fillColor: number = mapPolygon.getFillColor();
getHoles(): Array<Array<mapCommon.LatLng>>
Obtains holes in a MapPolygon.
MapPolygon holes: A MapPolygon may contain one or more interior holes, creating a "hollow" effect. These areas are left unfilled, allowing for more complex and diverse internal structures within the MapPolygon.
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:
| Type | Description |
|---|---|
| Array<Array<mapCommon.LatLng>> | Array of holes in a MapPolygon, which is a LatLng array. |
Example:
- let holes: Array<Array<mapCommon.LatLng>> = mapPolygon.getHoles();
getPoints(): Array<mapCommon.LatLng>
Obtains vertex coordinates of a MapPolygon.
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:
| Type | Description |
|---|---|
| Array<mapCommon.LatLng> | Vertex coordinates of a MapPolygon. |
Example:
- let points: Array<mapCommon.LatLng> = mapPolygon.getPoints();
getStrokeColor(): number
Obtains the stroke color of a MapPolygon's outline.
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:
| Type | Description |
|---|---|
| number | Color in ARGB format. |
Example:
- let strokeColor: number = mapPolygon.getStrokeColor();
getJointType(): mapCommon.JointType
Obtains the joint style of a MapPolygon.
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:
| Type | Description |
|---|---|
| mapCommon.JointType | Joint style of a MapPolygon. |
Example:
- let jointType: mapCommon.JointType = mapPolygon.getJointType();
getPatterns(): Array<mapCommon.PatternItem>
Obtains the pattern of a MapPolygon's outline.
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:
| Type | Description |
|---|---|
| Array<mapCommon.PatternItem> | Pattern of a MapPolygon's outline. |
Example:
- let patterns: Array<mapCommon.PatternItem> = mapPolygon.getPatterns();
getStrokeWidth(): number
Obtains the stroke width of a MapPolygon's outline.
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:
| Type | Description |
|---|---|
| number | Stroke width of a MapPolygon's outline, in pixels. |
Example:
- let strokeWidth: number = mapPolygon.getStrokeWidth();
isClickable(): boolean
Checks whether a MapPolygon is tappable.
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:
| Type | Description |
|---|---|
| boolean | Indicates whether a MapPolygon is tappable. - true: yes - false: no |
Example:
- let clickable: boolean = mapPolygon.isClickable();
isGeodesic(): boolean
Checks whether each segment of a MapPolygon is a geodesic.
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:
| Type | Description |
|---|---|
| boolean | Indicates whether each segment of a MapPolygon is a geodesic. - true: yes - false: no |
Example:
- let geodesic: boolean = mapPolygon.isGeodesic();
setClickable(clickable: boolean): void
Sets whether a MapPolygon is tappable.
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:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| clickable | boolean | Yes | Indicates whether a MapPolygon is tappable. Invalid values are not processed. - true: yes - false: no |
Example:
- mapPolygon.setClickable(true);
setFillColor(color: number): void
Sets the fill color of a MapPolygon.
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:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| color | number | Yes | Fill color of the MapPolygon, in ARGB format. Invalid values are not processed. |
Example:
- mapPolygon.setFillColor(0xff000FFF);
setGeodesic(geodesic: boolean): void
Sets whether to draw each segment of a MapPolygon as a geodesic.
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:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| geodesic | boolean | Yes | Indicates whether to draw each segment of a MapPolygon as a geodesic. Invalid values are not processed. - true: yes - false: no |
Example:
- mapPolygon.setGeodesic(true);
setHoles(holes: Array<Array<mapCommon.LatLng>>): void
Sets holes in a MapPolygon.
MapPolygon holes: A MapPolygon may contain one or more interior holes, creating a "hollow" effect. These areas are left unfilled, allowing for more complex and diverse internal structures within the MapPolygon.
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:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| holes | Array<Array<mapCommon.LatLng>> | Yes | Array of holes, which is a LatLng array. Invalid values are not processed. |
Example:
- let holes: Array<Array<mapCommon.LatLng>> = [
- [
- {
- latitude: 32.98,
- longitude: 121.76
- },
- {
- latitude: 32.98,
- longitude: 119.76
- },
- {
- latitude: 35.98,
- longitude: 119.76
- },
- {
- latitude: 35.98,
- longitude: 121.76
- }
- ]
- ];
- mapPolygon.setHoles(holes);
When coordinates of a hole coincide with the outline of the MapPolygon, it can lead to rendering anomalies, such as extra hollow regions being displayed.
setPoints(points: Array<mapCommon.LatLng>): void
Sets the vertex coordinates of a MapPolygon.
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:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| points | Array<mapCommon.LatLng> | Yes | Array of vertex coordinates of a MapPolygon. Invalid values are not processed. |
Example:
- let points: Array<mapCommon.LatLng> = [
- {
- latitude: 31.98,
- longitude: 115.76
- },
- {
- latitude: 31.98,
- longitude: 118.76
- },
- {
- latitude: 35.98,
- longitude: 118.76
- },
- {
- latitude: 35.98,
- longitude: 118.76
- }
- ];
- mapPolygon.setPoints(points);
setStrokeColor(color: number): void
Sets the stroke color of a MapPolygon's outline.
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:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| color | number | Yes | Stroke color of a MapPolygon's outline, in ARGB format. Invalid values are not processed. |
Example:
- mapPolygon.setStrokeColor(0xff00DB93);
setJointType(jointType: mapCommon.JointType): void
Sets the joint style of a MapPolygon.
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:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| jointType | mapCommon.JointType | Yes | Joint style. Invalid values are not processed. |
Example:
- mapPolygon.setJointType(mapCommon.JointType.ROUND);
setPatterns(patterns: Array<mapCommon.PatternItem>): void
Sets the pattern of a MapPolygon's outline.
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:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| patterns | Array<mapCommon.PatternItem> | Yes | Array of PatternItem objects. Invalid values are not processed. |
Example:
- let linePatterns: Array<mapCommon.PatternItem> = [
- {
- type: mapCommon.PatternItemType.DASH,
- length: 100
- },
- {
- type: mapCommon.PatternItemType.DOT,
- length: 100
- },
- {
- type: mapCommon.PatternItemType.GAP,
- length: 100
- }
- ];
- mapPolygon.setPatterns(linePatterns);
setStrokeWidth(width: number): void
Sets the stroke width of a MapPolygon's outline.
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:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| width | number | Yes | Stroke width, in px. The value must be greater than or equal to 0. Invalid values are not processed. |
Example:
- mapPolygon.setStrokeWidth(30);
Intelligent Assistant
Chat with our virtual assistant to get answers promptly.
Quick start
Helps you find desired resources with ease.