1、引入聚合插件及相应的样式文件
js插件:https://download.csdn.net/download/qq_48795482/90404737
样式文件1:https://download.csdn.net/download/qq_48795482/90404741
样式文件2:https://download.csdn.net/download/qq_48795482/90404743
html
<script src="/mapLib/leaflet.markercluster.js"></script>
<link rel="stylesheet" type="text/css" href="/mapLib/MarkerCluster.css" />
<link
rel="stylesheet"
type="text/css"
href="/mapLib/MarkerCluster.Default.css"
/>
2、调用插件函数得到聚合图层
javascript
this.clusterLayer = L.markerClusterGroup();
3、将相应的marker或者geojson的点图层添加到聚合图层中,点位会自动实现聚合。
javascript
that.clusterLayer.addLayer(that.geoJSONLayer[id]);