code Snippetlanguage CDNpackage_2 NPM
content_copy Copyopen_in_new Open
maptilersdk.config.apiKey = 'YOUR_MAPTILER_KEY' ;
const map = new maptilersdk. Map ({
container: 'map' ,
style: maptilersdk.MapStyle. STREETS ,
center: [ 2.3522 , 48.8566 ],
zoom: 11
});
const points = [];
for ( let i = 0 ; i < 80 ; i ++ ) {
points. push ({
type: 'Feature' ,
geometry: { type: 'Point' , coordinates: [ 2.25 + Math. random () * 0.25 , 48.8 + Math. random () * 0.15 ] },
properties: { name: 'Location ' + (i + 1 ) }
});
}
map. on ( 'load' , () => {
map. addSource ( 'points' , {
type: 'geojson' ,
data: { type: 'FeatureCollection' , features: points },
cluster: true ,
clusterMaxZoom: 14 ,
clusterRadius: 50
});
map. addLayer ({ id: 'clusters' , type: 'circle' , source: 'points' , filter: [ 'has' , 'point_count' ],
paint: { 'circle-color' : '#9C27B0' , 'circle-radius' : [ 'step' , [ 'get' , 'point_count' ], 15 , 10 , 22 , 30 , 30 ], 'circle-stroke-width' : 2 , 'circle-stroke-color' : '#ffffff' }
});
map. addLayer ({ id: 'cluster-count' , type: 'symbol' , source: 'points' , filter: [ 'has' , 'point_count' ],
layout: { 'text-field' : '{point_count_abbreviated}' , 'text-size' : 13 },
paint: { 'text-color' : '#ffffff' }
});
map. addLayer ({ id: 'unclustered' , type: 'circle' , source: 'points' , filter: [ '!' , [ 'has' , 'point_count' ]],
paint: { 'circle-color' : '#ce93d8' , 'circle-radius' : 6 , 'circle-stroke-width' : 1 , 'circle-stroke-color' : '#ffffff' }
});
}); content_copy Copyopen_in_new Open
<! DOCTYPE html >
< html >
< head >
< meta charset = "utf-8" />
< meta name = "viewport" content = "width=device-width, initial-scale=1.0" />
< link rel = "stylesheet" href = "https://cdn.maptiler.com/maptiler-sdk-js/v4.1.0/maptiler-sdk.css" />
< script src = "https://cdn.maptiler.com/maptiler-sdk-js/v4.1.0/maptiler-sdk.umd.min.js" ></ script >
< style >
body { margin : 0 ; padding : 0 ; }
#map { width : 100 % ; height : 100 vh ; }
</ style >
</ head >
< body >
< div id = "map" ></ div >
< script >
maptilersdk.config.apiKey = 'YOUR_MAPTILER_KEY' ;
const map = new maptilersdk. Map ({
container: 'map' ,
style: maptilersdk.MapStyle. STREETS ,
center: [ 2.3522 , 48.8566 ],
zoom: 11
});
const points = [];
for ( let i = 0 ; i < 80 ; i ++ ) {
points. push ({
type: 'Feature' ,
geometry: { type: 'Point' , coordinates: [ 2.25 + Math. random () * 0.25 , 48.8 + Math. random () * 0.15 ] },
properties: { name: 'Location ' + (i + 1 ) }
});
}
map. on ( 'load' , () => {
map. addSource ( 'points' , {
type: 'geojson' ,
data: { type: 'FeatureCollection' , features: points },
cluster: true ,
clusterMaxZoom: 14 ,
clusterRadius: 50
});
map. addLayer ({ id: 'clusters' , type: 'circle' , source: 'points' , filter: [ 'has' , 'point_count' ],
paint: { 'circle-color' : '#9C27B0' , 'circle-radius' : [ 'step' , [ 'get' , 'point_count' ], 15 , 10 , 22 , 30 , 30 ], 'circle-stroke-width' : 2 , 'circle-stroke-color' : '#ffffff' }
});
map. addLayer ({ id: 'cluster-count' , type: 'symbol' , source: 'points' , filter: [ 'has' , 'point_count' ],
layout: { 'text-field' : '{point_count_abbreviated}' , 'text-size' : 13 },
paint: { 'text-color' : '#ffffff' }
});
map. addLayer ({ id: 'unclustered' , type: 'circle' , source: 'points' , filter: [ '!' , [ 'has' , 'point_count' ]],
paint: { 'circle-color' : '#ce93d8' , 'circle-radius' : 6 , 'circle-stroke-width' : 1 , 'circle-stroke-color' : '#ffffff' }
});
});
</ script >
</ body >
</ html > content_copy Copyopen_in_new Open
import * as maptilersdk from '@maptiler/sdk' ;
import '@maptiler/sdk/dist/maptiler-sdk.css' ;
maptilersdk.config.apiKey = 'YOUR_MAPTILER_KEY' ;
const map = new maptilersdk. Map ({
container: 'map' ,
style: maptilersdk.MapStyle. STREETS ,
center: [ 2.3522 , 48.8566 ],
zoom: 11
});
const points = [];
for ( let i = 0 ; i < 80 ; i ++ ) {
points. push ({
type: 'Feature' ,
geometry: { type: 'Point' , coordinates: [ 2.25 + Math. random () * 0.25 , 48.8 + Math. random () * 0.15 ] },
properties: { name: 'Location ' + (i + 1 ) }
});
}
map. on ( 'load' , () => {
map. addSource ( 'points' , {
type: 'geojson' ,
data: { type: 'FeatureCollection' , features: points },
cluster: true ,
clusterMaxZoom: 14 ,
clusterRadius: 50
});
map. addLayer ({ id: 'clusters' , type: 'circle' , source: 'points' , filter: [ 'has' , 'point_count' ],
paint: { 'circle-color' : '#9C27B0' , 'circle-radius' : [ 'step' , [ 'get' , 'point_count' ], 15 , 10 , 22 , 30 , 30 ], 'circle-stroke-width' : 2 , 'circle-stroke-color' : '#ffffff' }
});
map. addLayer ({ id: 'cluster-count' , type: 'symbol' , source: 'points' , filter: [ 'has' , 'point_count' ],
layout: { 'text-field' : '{point_count_abbreviated}' , 'text-size' : 13 },
paint: { 'text-color' : '#ffffff' }
});
map. addLayer ({ id: 'unclustered' , type: 'circle' , source: 'points' , filter: [ '!' , [ 'has' , 'point_count' ]],
paint: { 'circle-color' : '#ce93d8' , 'circle-radius' : 6 , 'circle-stroke-width' : 1 , 'circle-stroke-color' : '#ffffff' }
});
});
maptilersdk.config.apiKey = 'YOUR_MAPTILER_KEY';
const map = new maptilersdk.Map({
container: 'map',
style: maptilersdk.MapStyle.STREETS,
center: [2.3522, 48.8566],
zoom: 11
});
const points = [];
for (let i = 0; i < 80; i++) {
points.push({
type: 'Feature',
geometry: { type: 'Point', coordinates: [2.25 + Math.random() * 0.25, 48.8 + Math.random() * 0.15] },
properties: { name: 'Location ' + (i + 1) }
});
}
map.on('load', () => {
map.addSource('points', {
type: 'geojson',
data: { type: 'FeatureCollection', features: points },
cluster: true,
clusterMaxZoom: 14,
clusterRadius: 50
});
map.addLayer({ id: 'clusters', type: 'circle', source: 'points', filter: ['has', 'point_count'],
paint: { 'circle-color': '#9C27B0', 'circle-radius': ['step', ['get', 'point_count'], 15, 10, 22, 30, 30], 'circle-stroke-width': 2, 'circle-stroke-color': '#ffffff' }
});
map.addLayer({ id: 'cluster-count', type: 'symbol', source: 'points', filter: ['has', 'point_count'],
layout: { 'text-field': '{point_count_abbreviated}', 'text-size': 13 },
paint: { 'text-color': '#ffffff' }
});
map.addLayer({ id: 'unclustered', type: 'circle', source: 'points', filter: ['!', ['has', 'point_count']],
paint: { 'circle-color': '#ce93d8', 'circle-radius': 6, 'circle-stroke-width': 1, 'circle-stroke-color': '#ffffff' }
});
}); <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="https://cdn.maptiler.com/maptiler-sdk-js/v4.1.0/maptiler-sdk.css" />
<script src="https://cdn.maptiler.com/maptiler-sdk-js/v4.1.0/maptiler-sdk.umd.min.js"></script>
<style>
body { margin: 0; padding: 0; }
#map { width: 100%; height: 100vh; }
</style>
</head>
<body>
<div id="map"></div>
<script>
maptilersdk.config.apiKey = 'YOUR_MAPTILER_KEY';
const map = new maptilersdk.Map({
container: 'map',
style: maptilersdk.MapStyle.STREETS,
center: [2.3522, 48.8566],
zoom: 11
});
const points = [];
for (let i = 0; i < 80; i++) {
points.push({
type: 'Feature',
geometry: { type: 'Point', coordinates: [2.25 + Math.random() * 0.25, 48.8 + Math.random() * 0.15] },
properties: { name: 'Location ' + (i + 1) }
});
}
map.on('load', () => {
map.addSource('points', {
type: 'geojson',
data: { type: 'FeatureCollection', features: points },
cluster: true,
clusterMaxZoom: 14,
clusterRadius: 50
});
map.addLayer({ id: 'clusters', type: 'circle', source: 'points', filter: ['has', 'point_count'],
paint: { 'circle-color': '#9C27B0', 'circle-radius': ['step', ['get', 'point_count'], 15, 10, 22, 30, 30], 'circle-stroke-width': 2, 'circle-stroke-color': '#ffffff' }
});
map.addLayer({ id: 'cluster-count', type: 'symbol', source: 'points', filter: ['has', 'point_count'],
layout: { 'text-field': '{point_count_abbreviated}', 'text-size': 13 },
paint: { 'text-color': '#ffffff' }
});
map.addLayer({ id: 'unclustered', type: 'circle', source: 'points', filter: ['!', ['has', 'point_count']],
paint: { 'circle-color': '#ce93d8', 'circle-radius': 6, 'circle-stroke-width': 1, 'circle-stroke-color': '#ffffff' }
});
});
</script>
</body>
</html> import * as maptilersdk from '@maptiler/sdk';
import '@maptiler/sdk/dist/maptiler-sdk.css';
maptilersdk.config.apiKey = 'YOUR_MAPTILER_KEY';
const map = new maptilersdk.Map({
container: 'map',
style: maptilersdk.MapStyle.STREETS,
center: [2.3522, 48.8566],
zoom: 11
});
const points = [];
for (let i = 0; i < 80; i++) {
points.push({
type: 'Feature',
geometry: { type: 'Point', coordinates: [2.25 + Math.random() * 0.25, 48.8 + Math.random() * 0.15] },
properties: { name: 'Location ' + (i + 1) }
});
}
map.on('load', () => {
map.addSource('points', {
type: 'geojson',
data: { type: 'FeatureCollection', features: points },
cluster: true,
clusterMaxZoom: 14,
clusterRadius: 50
});
map.addLayer({ id: 'clusters', type: 'circle', source: 'points', filter: ['has', 'point_count'],
paint: { 'circle-color': '#9C27B0', 'circle-radius': ['step', ['get', 'point_count'], 15, 10, 22, 30, 30], 'circle-stroke-width': 2, 'circle-stroke-color': '#ffffff' }
});
map.addLayer({ id: 'cluster-count', type: 'symbol', source: 'points', filter: ['has', 'point_count'],
layout: { 'text-field': '{point_count_abbreviated}', 'text-size': 13 },
paint: { 'text-color': '#ffffff' }
});
map.addLayer({ id: 'unclustered', type: 'circle', source: 'points', filter: ['!', ['has', 'point_count']],
paint: { 'circle-color': '#ce93d8', 'circle-radius': 6, 'circle-stroke-width': 1, 'circle-stroke-color': '#ffffff' }
});
});