new GraphicLayer(id, options)
Usage
import { GraphicLayer } from '@supermapgis/iclient-mapboxgl';
new GraphicLayer(id, options);<script type="text/javascript" src="https://iclient.supermap.io/dist/mapboxgl/iclient-mapboxgl.js"></script>
<script>
new mapboxgl.supermap.GraphicLayer({paramsNames});
</script>| Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
id |
string |
可选
图层 ID。默认使用 CommonUtil.createUniqueID("graphicLayer_") 创建专题图层 ID。 |
||||||||||||||||||||||||||||||||||||||||||||
options |
Object |
参数。
|
- Version:
- 11.1.0
API Relations
Members
-
idstring
-
高效率点图层 ID。
Methods
-
addGraphics(graphics)
mapboxgl/overlay/GraphicLayer.js, line 112 -
添加点要素,不会覆盖之前的要素。
Name Type Description graphicsArray.<Graphic> 点要素对象数组。
-
deprecated addTo(map)
mapboxgl/overlay/GraphicLayer.js, line 43 -
添加该图层,将在下个版本废弃,请使用 onAdd() 代替。
Name Type Description mapmapboxgl.Map mapboxgl Map 对象。
Returns:
this -
clear()
mapboxgl/overlay/GraphicLayer.js, line 162 -
释放图层资源。
-
getGraphicBy(property, value){Graphic}
mapboxgl/overlay/GraphicLayer.js, line 121 -
在 Vector 的要素数组 graphics 里面遍历每一个 graphic,当 graphic[property]===value 时,返回此 graphic(并且只返回第一个)。
Name Type Description propertystring graphic 的某个属性名称。
valuestring property 所对应的值。
Returns:
Type Description Graphic 一个匹配的 graphic。 -
getGraphicById(graphicId){Graphic}
mapboxgl/overlay/GraphicLayer.js, line 132 -
通过给定一个 ID,返回对应的矢量要素。
Name Type Description graphicIdstring 矢量要素的属性 ID。
Returns:
Type Description Graphic 一个匹配的 graphic。 -
getGraphicsByAttribute(attrName, attrValue){Array.<Graphic>}
mapboxgl/overlay/GraphicLayer.js, line 142 -
通过给定一个属性的 key 值和 value 值,返回所有匹配的要素数组。
Name Type Description attrNamestring 属性的 key 值。
attrValuestring 属性的 value 值。
Returns:
Type Description Array.<Graphic> 一个匹配的 graphic 数组。 -
getMapState(){Object}
mapboxgl/overlay/GraphicLayer.js, line 207 -
获取当前地图状态。
Returns:
Type Description Object 地图状态,包含地图状态信息。 -
getState(){Object}
mapboxgl/overlay/GraphicLayer.js, line 198 -
获取当前地图及图层状态。
Returns:
Type Description Object 地图及图层状态,包含地图状态信息和本图层相关状态信息。 -
moveTo(layerID, before)
mapboxgl/overlay/GraphicLayer.js, line 178 -
将图层移动到某个图层之前。
Name Type Default Description layerIDstring 待插入的图层 ID。
beforeboolean true 可选 是否将本图层插入到图层 ID 为 layerID 的图层之前。
-
onAdd(map){GraphicLayer}
mapboxgl/overlay/GraphicLayer.js, line 55 -
添加该图层。
Name Type Description mapmapboxgl.Map mapboxgl Map 对象。
Returns:
Type Description GraphicLayer -
deprecated onRemove()
mapboxgl/overlay/GraphicLayer.js, line 68 -
删除该图层,并释放图层资源。
-
remove()
mapboxgl/overlay/GraphicLayer.js, line 170 -
删除该图层。
-
removeGraphics(graphics)
mapboxgl/overlay/GraphicLayer.js, line 153 -
删除要素数组,默认将删除所有要素。
Name Type Default Description graphicsArray.<Graphic> null 可选 删除的 graphics 数组。
-
render()
mapboxgl/overlay/GraphicLayer.js, line 77 -
渲染图层。
-
setGraphics(graphics)
mapboxgl/overlay/GraphicLayer.js, line 103 -
设置绘制的点要素数据,会覆盖之前的所有要素。
Name Type Description graphicsArray.<Graphic> 点要素对象数组。
-
setStyle(styleOptions)
mapboxgl/overlay/GraphicLayer.js, line 85 -
设置图层整体样式。
Name Type Description styleOptionsObject 样式对象。
Name Type Default Description colorArray.<number> [0, 0, 0, 255] 可选 点颜色。
radiusnumber 10 可选 点半径,单位为像素。
opacitynumber 0.8 可选 不透明度。
highlightColorArray.<number> [0, 0, 128, 128] 可选 高亮颜色,目前只支持 rgba 数组。
radiusScalenumber 1 可选 点放大倍数。
radiusMinPixelsnumber 0 可选 半径最小值,单位为像素。
radiusMaxPixelsnumber Number.MAX_SAFE_INTEGER 可选 半径最大值,单位为像素。
strokeWidthnumber 1 可选 边框大小。
outlineboolean false 可选 是否显示边框。
-
setVisibility(visibility)
mapboxgl/overlay/GraphicLayer.js, line 188 -
设置图层可见性。
Name Type Description visibilityboolean 可选 是否显示图层(当前地图的 resolution 在最大最小 resolution 之间)。