Buildings
AMap.Buildings
3D layer of building blocks. Construct a 3D layer object of building blocks, and set layer properties through BuildingLayerOpts
new AMap.Buildings(opts: BuildingLayerOpts)Parameter
opts(BuildingLayerOpts): 3D layer parameters of building blocks
Demo
//Create building layer
var buildings = new AMap.Buildings({
heightFactor: 1,
wallColor: [255, 0, 0, 1],
roofColor: "rgba(0,0,255,0.5)",
});
//Add building layer to map
var map = new AMap.Map("container", {
viewMode: "3D",
pitch: 60,
rotation: -35,
layers: [buildings],
zoom: 17,
showBuildingBlock: false,
showOversea: true, //Enable world Map
});Method
setStyle(styleOpts)
Set building layer style
Parameter:
Demo:
var options = {
hideWithoutStyle:false,//Whether to hide buildings outside the set area
areas:[{ //Fence 1
//visible:false,//Whether it is visible
rejectTexture:true,//Whether to block the texture of custom maps
color1: 'ffffff00',//Roof color
color2: 'ffffcc00',//Floor color
path: [[116.473606,39.995997],[116.473005,39.995482],[116.474179,39.996516],[116.473606,39.995997]]
},
{ //Fence 2
color1: 'ff99ff00',
color2: 'ff999900',
path: [[116.474609,39.993478],[116.474489,39.993495],[116.47469,39.99348],[116.474609,39.993478]]
}]
};
buildings.setStyle(options); //This color scheme has higher priority than custom mapStylegetOptions()
Get layer parameter information
return value: (Object) Layer Parameter Information
Demo:
buildings.getOptions();setzIndex(zIndex)
Set the layer level, the higher the number, the higher the layer level
Parameter: zIndex (Number) Layer Level Value
Demo:
buildings.setzIndex(10);setOpacity(opacity)
Set the layer opacity, range [0 ~ 1], 1 means completely opaque, 0 means completely transparent
Parameter: opacity(Number) Layer opacity
Demo:
buildings.setOpacity(0.5);getZooms()
Get the display level range of the layer, the default range is [2-30]
return value: ([Number, Number]) The Displayable Level Range of This Layer
Demo:
buildings.getZooms()setZooms(zooms)
Set the Displayable Level Range of This Layer
Parameter: zooms([Number, Number]) The Displayable Level Range of This Layer
Demo:
buildings.setZooms([8,12]);show()
Set Layer to Visible
Demo:
buildings.show();hide()
Set Layer to Hidden
Demo:
buildings.hide();destroy()
Destroy Layer
Demo:
buildings.destroy()