Cluster Marker
Add cluster markers to map.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="https://cdn.smartmaps.cloud/packages/smartmaps/maps/umd/maps.min.js"></script>
<script
src="https://cdn.smartmaps.cloud/packages/leaflet-markercluster/1.5.3/leaflet.markercluster.js"></script>
<link rel="stylesheet"
href="https://cdn.smartmaps.cloud/packages/leaflet-markercluster/1.5.3/MarkerCluster.Default.css">
<style>
body {
margin: 0;
padding: 0;
}
html,
body,
#map {
height: 100%;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
const map = new smartmaps.maps.Map('map', 'INSERT API-KEY', {
zoom: 10,
});
var markers = L.markerClusterGroup({
disableClusteringAtZoom: 19
});
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
var geoJsonLayer = smartmaps.maps.geoJson(JSON.parse(this.responseText), {
onEachFeature: function (feature, layer) {
layer.bindPopup(feature.properties.objekt);
}
});
markers.addLayer(geoJsonLayer);
map.addLayer(markers);
map.fitBounds(markers.getBounds());
}
};
xmlhttp.open("GET", "../../data/bonn_small.geojson.json", true);
xmlhttp.send();
</script>
</body>
</html>