import { map, mapCommon } from '@kit.MapKit';
import { image } from '@kit.ImageKit'; Bubble, which inherits from BasePriorityOverlay. An instance of this type will be returned when the addBubble 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 bubbleOptions: mapCommon.BubbleParams = {
positions: [[{
latitude: 31.98,
longitude: 118.766
}]],
// The icons must be stored in the resources/rawfile directory.
icons: [
'icon.png',
'icon.png',
'icon.png',
'icon.png'
],
forceVisible: true,
priority: 3,
minZoom: 2,
maxZoom: 20,
visible: true,
zIndex: 1
};
let bubble: map.Bubble = await this.mapController.addBubble(bubbleOptions); setIcons(icons: Array<string | image.PixelMap | Resource>): Promise<void>
Sets the icons of a Bubble. This API uses a promise to return the result.
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 |
|---|---|---|---|
| icons | Array<string | image.PixelMap | Resource> | Yes | Bubble icon. Invalid values are not processed. - You must set the icons for four directions. The icons must have the same height and width. - Images in JPG, JPEG, PNG, GIF (only the first frame will be displayed), WEBP, and SVG formats are supported. - This input parameter of the string type supports the following formats: - Relative resource path: The icons are stored in resources/rawfile. Set icons to the relative paths of the icon files in the rawfile folder. - toDataURL format: For example, set icons to image/png;base64,<Base64-encoded byte value of the icon file>. Note: Since version 5.0.0(12), icon supports the Resource and image.PixelMap types. |
Returns:
| Type | Description |
|---|---|
| Promise<void> | Promise that returns no value. |
Example:
// The icons must be stored in the resources/rawfile directory. let icons: Array<string | image.PixelMap | Resource> = [ 'test1.png', 'test2.png', 'test3.png', 'test4.png' ]; await bubble.setIcons(icons);
setPositions(positions: Array<Array<mapCommon.LatLng>>): void
Sets the candidate position coordinates of a Bubble.
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 |
|---|---|---|---|
| positions | Array<Array<mapCommon.LatLng>> | Yes | Candidate position coordinates of a Bubble. Invalid values are not processed. |
Example:
let positions: Array<Array<mapCommon.LatLng>> = [[
{
latitude: 31.9844,
longitude: 118.7112
}, {
latitude: 31.9844,
longitude: 118.7262
}, {
latitude: 31.9844,
longitude: 118.7362
}, {
latitude: 31.9844,
longitude: 118.7462
}, {
latitude: 31.9844,
longitude: 118.7562
}, {
latitude: 31.9844,
longitude: 118.7662
}, {
latitude: 31.9844,
longitude: 118.7762
}
]];
bubble.setPositions(positions);