聚合

Leaflet.markercluster 是一个提供动态的标识聚类功能的 Leaflet 插件库。

引入插件 Leaflet.markercluster 包括两种方式:

下载 Leaflet.markercluster

1.进入 github 下载 Leaflet.markercluster,下载地址为:

https://github.com/Leaflet/Leaflet.markercluster

2.&ltscript&gt标签与&ltlink&gt标签引入:

<script src="leaflet.markercluster.js"></script>
<link rel="stylesheet" href="MarkerCluster.Default.css"/>
<link rel="stylesheet" href="MarkerCluster.css"/>

直接通过 cdn 引入

<script src="https://cdn.bootcdn.net/ajax/libs/leaflet.markercluster/1.3.0/leaflet.markercluster.js"></script>
<link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/leaflet.markercluster/1.3.0/MarkerCluster.Default.css"/>
<link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/leaflet.markercluster/1.3.0/MarkerCluster.css"/>
resultLayer = L.markerClusterGroup({
    spiderfyOnMaxZoom: false,
    //设置为true时显示聚类所占据的范围
    showCoverageOnHover: false,
    //设置为true时会向低一级聚类缩放
    zoomToBoundsOnClick: false
});
result.features.map(function (feature) {
    var latLng = L.CRS.EPSG3857.unproject(L.point(feature.geometry.coordinates));
    resultLayer.addLayer(L.marker(latLng));
});
resultLayer.addTo(map);

查看完整示例代码

results matching ""

    No results matching ""