LabelsLayer
AMap.LabelsLayer
Annotation layer, used to carry LabelMarker markers. Construct a LabelsLayer object and set the layer properties through LabelsLayerOptions
new AMap.LabelsLayer(opts: LabelsLayerOptions)Parameter
options(LabelsLayerOptions): Annotation Layer Parameters
Demo
var labelsLayer = new AMap.LabelsLayer({
zooms: [3, 20],
zIndex: 1000,
collision: true, //Whether annotations within this layer avoid each other
allowCollision: true, //Whether to avoid between different annotation layers
});
map.add(labelsLayer);Method
getCollision()
Get whether the annotation layer supports internal annotation avoidance
return value: (Boolean) Return true if avoidance is supported, return false if avoidance is not supported
Demo:
labelsLayer.getCollision();setCollision(collision)
Set whether the annotation layer supports internal annotation avoidance
Parameter: collision (boolean) Pass true to support avoidance, pass false to not support avoidance
Demo:
labelsLayer.setCollision(true);getAllowCollision()
Get whether the annotation layer allows other layers to avoid annotations
return value: (Boolean) Returns true if avoidance is allowed, returns false if avoidance is not allowed
Demo:
labelsLayer.getAllowCollision();setAllowCollision(allowCollision)
Set whether the annotation layer allows avoidance by other layer annotations. Enabling this feature allows map annotations to avoid LabelMarker
Parameter: allowCollision(boolean) Pass true to allow avoidance, pass false to disallow avoidance
Demo:
labelsLayer.setAllowCollision(true);getOpacity()
Get the transparency of the annotation layer
return value: (Number) opacity layer transparency
Demo:
labelsLayer.getOpacity();setOpacity(opacity)
Set layer transparency, range [0 ~ 1], where 1 represents completely opaque and 0 represents completely transparent
Parameter: opacity (Number) Layer transparency
Demo:
labelsLayer.setOpacity(0.5);getZooms()
Get the display level range of the annotation layer
return value: ([Number, Number]) The displayable level range of this layer
Demo:
labelsLayer.getZooms();setZooms(zooms)
Set the display level range of the annotation layer
Parameter: zooms([Number, Number]) Zoom Range Displayable by This Layer
Demo:
labelsLayer.setZooms([8,12]);getzIndex()
Get Label Layer Overlay Order
return value: (Number) zIndex Layer Level
Demo:
labelsLayer.getzIndex();setzIndex(zIndex)
Set Label Layer Overlay Order
Parameter: zIndex (Number) Layer Z-index Value
Demo:
labelsLayer.setzIndex(10);add(labelMarkers)
Add labelMarker to the label layer
Parameter: labelMarkers (LabelMarker | Array<LabelMarker>) Can add a single label or label array
Demo:
labelsLayer.add(labelMarker); //Detailed example reference tutorial documentremove(labelMarkers)
Remove labelMarker from the label layer
Parameter: labelMarkers (LabelMarker | Array<LabelMarker>) Can remove a single label or label array
Demo:
labelsLayer.remove(labelMarker); //Detailed example reference tutorial documentclear()
Clear all annotations on the annotation layer
Demo:
labelsLayer.clear();show()
Set layer visibility to visible
Demo:
labelsLayer.show();hide()
Set layer visibility to hidden
Demo:
labelsLayer.hide();getAllOverlays()
Retrieve all annotation objects within the annotation layer
return value: (Array<any>) All annotation objects within the annotation layer
Demo:
labelsLayer.getAllOverlays();