更新时间:2026/07/27 10:37
您当前查看的是 JSAPI GL 历史版本文档。该版本仅用于维护现有项目,不建议用于新项目开发。新项目请使用 JSAPI 4.0,如需升级现有项目,请参考升级指南。
You are viewing the legacy JSAPI GL documentation. This version is maintained for existing projects only and is not recommended for new development. For new projects, use the JSAPI 4.0 documentation. If you are upgrading an existing project, please refer to the Migration Guide.
You are viewing the legacy JSAPI GL documentation. This version is maintained for existing projects only and is not recommended for new development. For new projects, use the JSAPI 4.0 documentation. If you are upgrading an existing project, please refer to the Migration Guide.
点聚合
简介
JSAPI GL用于展示海量点标记,将点标记按照距离、属性、地理围栏进行聚合,以提高地图绘制性能。
支持用户灵活自定义可视化样式。
类参考
示例代码
- 1引入JavaScript// npm引入import Cluster from '@bmapgl-plugin/cluster';HTML// CDN引入<script src="//unpkg.com/@bmapgl-plugin/cluster"></script>
- 2默认聚合效果TSXconst points = [{type: 'Feature',properties: {},geometry: {coordinates: [116.38856190676842, 39.909763838319805],type: 'Point',},},// ......];const cluster = new Cluster.View(map);cluster.setData(points);cluster.on(Cluster.ClusterEvent.CLICK, (e: Cluster.ClusterElement) => {console.log('ClusterEvent.CLICK', e);});cluster.on(Cluster.ClusterEvent.MOUSE_OUT, (e: Cluster.ClusterElement) => {console.log('ClusterEvent.MOUSE_OUT', e);});cluster.on(Cluster.ClusterEvent.MOUSE_OVER, (e: Cluster.ClusterElement) => {console.log('ClusterEvent.MOUSE_OVER', e);});cluster.on(Cluster.ClusterEvent.CHANGE, (e: [any, any]) => {console.log('ClusterEvent.CHANGE', e);});
本篇文章对您是否有帮助?