BuildingOverlay. The 3D building effect is available at zoom level 16 or higher. An instance of this type will be returned when the addBuildingOverlay 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 5.0.0(12).
System capability: SystemCapability.Map.Core
Since: 5.0.0(12)
Example:
let points: Array<mapCommon.LatLng> = [
{
latitude: 31.984794,
longitude: 118.765865
},
{
latitude: 31.98468,
longitude: 118.766076
},
{
latitude: 31.98472,
longitude: 118.766116
},
{
latitude: 31.98463,
longitude: 118.766292
},
{
latitude: 31.984586,
longitude: 118.766251
},
{
latitude: 31.984536,
longitude: 118.766344
},
{
latitude: 31.984633,
longitude: 118.766446
},
{
latitude: 31.9848,
longitude: 118.766285
},
{
latitude: 31.984925,
longitude: 118.766312
},
{
latitude: 31.985282,
longitude: 118.766661
},
{
latitude: 31.985438,
longitude: 118.766419
},
{
latitude: 31.985801,
longitude: 118.766755
},
{
latitude: 31.985856,
longitude: 118.766504
},
{
latitude: 31.985785,
longitude: 118.766434
},
{
latitude: 31.985821,
longitude: 118.766278
},
{
latitude: 31.985897,
longitude: 118.766311
},
{
latitude: 31.985944,
longitude: 118.766095
},
{
latitude: 31.985909,
longitude: 118.766069
},
{
latitude: 31.985794,
longitude: 118.765989
},
{
latitude: 31.9857,
longitude: 118.766029
},
{
latitude: 31.985658,
longitude: 118.766164
},
{
latitude: 31.985647,
longitude: 118.766271
},
{
latitude: 31.985574,
longitude: 118.766297
},
{
latitude: 31.985458,
longitude: 118.766285
},
{
latitude: 31.985271,
longitude: 118.766002
},
{
latitude: 31.985219,
longitude: 118.766002
},
{
latitude: 31.985135,
longitude: 118.766029
},
{
latitude: 31.985093,
longitude: 118.766083
},
{
latitude: 31.985019,
longitude: 118.766109
},
{
latitude: 31.984978,
longitude: 118.766083
},
{
latitude: 31.984794,
longitude: 118.765865
}
];
// Reverse the sequence of points to meet the map drawing requirements.
points.reverse();
// BuildingOverlay parameters.
let buildingOverlayOptions: mapCommon.BuildingOverlayParams =
{
// Scope parameter of the BuildingOverlay (points are drawn in clockwise order).
points: points,
// Height of the BuildingOverlay.
totalHeight: 51,
// Height of the selected floor in the BuildingOverlay.
floorBottomHeight: 33,
// Top color of the BuildingOverlay.
topFaceColor: 0xffa4b8f7,
// Side color of the BuildingOverlay.
sideFaceColor: 0x44a4b8f7,
// Color of the selected floor in the BuildingOverlay.
floorColor: 0xff000000,
// Display level of the BuildingOverlay.
showLevel: 16,
// Animation duration for the selected floor in the BuildingOverlay rising from the bottom.
animationDuration: 5000,
// Side texture of the BuildingOverlay.
sideTexture: {
image: $r("app.media.side_tex"),
height: 3,
width: 3
},
// Texture of the selected floor in the BuildingOverlay.
floorTexture: {
image: $r("app.media.floor_tex"),
height: 3,
width: 3
}
}
let buildingOverlay: map.BuildingOverlay = await this.mapController.addBuildingOverlay(buildingOverlayOptions); getId(): string
Returns the ID of a BuildingOverlay.
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 5.0.0(12).
System capability: SystemCapability.Map.Core
Since: 5.0.0(12)
Returns:
| Type | Description |
|---|---|
| string | BuildingOverlay ID. |
Example:
let id: string = buildingOverlay.getId();
remove(): void
Removes a BuildingOverlay.
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 5.0.0(12).
System capability: SystemCapability.Map.Core
Since: 5.0.0(12)
Example:
buildingOverlay.remove();
setSideVisible(visible: boolean): void
Sets whether to display the sides and top of a BuildingOverlay. If you do not need to display a BuildingOverlay, set both setSideVisible and setFloorVisible to false.
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 5.0.0(12).
System capability: SystemCapability.Map.Core
Since: 5.0.0(12)
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| visible | boolean | Yes | Indicates whether to display the sides and top of a BuildingOverlay. - true: yes - false: no |
Example:
buildingOverlay.setSideVisible(true);
setFloorVisible(visible: boolean): void
Sets whether to display the selected floor.
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 5.0.0(12).
System capability: SystemCapability.Map.Core
Since: 5.0.0(12)
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| visible | boolean | Yes | Indicates whether to display the selected floor. - true: yes - false: no |
Example:
buildingOverlay.setFloorVisible(true);
setFloorBottomHeight(height: number): void
Sets the base height of the selected floor above the ground.
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 5.0.0(12).
System capability: SystemCapability.Map.Core
Since: 5.0.0(12)
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| height | number | Yes | Base height of the selected floor above the ground, in meters. The value must be greater than or equal to 0. Invalid values are not processed. |
Example:
buildingOverlay.setFloorBottomHeight(80);