Map with marker clusters
author(s): Wojciech Chmiel
by Geo George
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.6/proj4.js"></script>
<script src="https://code.highcharts.com/maps/highmaps.js"></script>
<script src="https://code.highcharts.com/stock/modules/data.js"></script>
<script src="https://code.highcharts.com/mapdata/custom/europe.js"></script>
<script src="https://code.highcharts.com/modules/marker-clusters.js"></script>
<script src="https://code.highcharts.com/modules/coloraxis.js"></script>
<div id="container"></div>
CSS
#container {
min-width: 310px;
max-width: 700px;
height: 600px;
margin: 0 auto;
}
JavaScript
Highcharts.getJSON('https://cdn.jsdelivr.net/gh/highcharts/highcharts@1e9e659c2d60fbe27ef0b41e2f93112dd68fb7a3/samples/data/european-train-stations-near-airports.json', function (data) {
data=data.map(function(a){
a["color"]="red";
a["y"]=10000;
return a;
})
Highcharts.mapChart('container', {
chart: {
map: 'custom/europe'
},
title: {
text: 'European Train Stations Near Airports'
},
subtitle: {
text: 'Source: <a href="https://github.com/trainline-eu/stations">' +
'github.com/trainline-eu/stations</a>'
},
mapNavigation: {
enabled: true
},
tooltip: {
headerFormat: '',
pointFormat: '<b>{point.name}</b><br>Lat: {point.lat:.2f}, Lon: {point.lon:.2f}'
},
plotOptions: {
mappoint: {
cluster: {
enabled: true,
//allowOverlap: false,
dataLabels:{
enabled:false
},
marker: {
radius: 10
},
animation: {
duration: 450
},
layoutAlgorithm: {
type: 'grid',
gridSize: 200
},
zones: [ {
from: 0,
to: 100,
marker: {
radius: 0
}
}]
}
}
},
series: [{
name: 'Basemap',
borderColor: '#A0A0A0',
nullColor: 'rgba(177, 244, 177, 0.5)',
showInLegend: false
}, {
type: 'mappoint',
enableMouseTracking: true,
//colorKey: 'clusterPointsAmount',
name: 'Cities',
data: data
}]
});
});