SOURCE

console 命令行工具 X clear

                    
>
console
//创建地图,并设置初始中心点和级别

	var map = L.map('map').setView([35.53222622770337, 106.875], 5);

	L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw', {
		maxZoom: 18,
		attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, ' +
			'<a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
			'Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
		id: 'mapbox/streets-v11',
		tileSize: 512,
		zoomOffset: -1
	}).addTo(map); 
//创建聚合图标注组
var markers = new L.MarkerClusterGroup();
var markersList = [];
//生成固定个坐标
function populate() {
    for (var i = 0; i < 1000; i++) {
        var m = new L.Marker(getRandomLatLng(map));
        markersList.push(m);
        markers.addLayer(m); 
    }
    return false;
}
//在屏幕范围内随机生成一个坐标
function getRandomLatLng(map) {
    var bounds = map.getBounds(),
    southWest = bounds.getSouthWest(),
    northEast = bounds.getNorthEast(),
    lngSpan = northEast.lng - southWest.lng,
    latSpan = northEast.lat - southWest.lat;
    return new L.LatLng(
        southWest.lat + latSpan * Math.random(),
        southWest.lng + lngSpan * Math.random());
}
markers.on('clusterclick', function (a) {
    //console.log(a);
});
markers.on('click', function (a) {
    //alert('marker ' + a.layer);
});
populate();
//将聚合图添加到地图上
map.addLayer(markers);
<div id="map"></div>
body{
    padding: 0;
    margin: 0
}
#map{
    width: 100%;
    height: 100vh;
}