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: 13
});
function fuzzyCircle ( center , radiusKm , points = 64 ) {
const coords = [];
for ( let i = 0 ; i <= points; i ++ ) {
const angle = (i / points) * 2 * Math. PI ;
const dx = radiusKm / ( 111.32 * Math. cos (center[ 1 ] * Math. PI / 180 ));
const dy = radiusKm / 110.574 ;
coords. push ([center[ 0 ] + dx * Math. cos (angle), center[ 1 ] + dy * Math. sin (angle)]);
}
return { type: 'Feature' , geometry: { type: 'Polygon' , coordinates: [coords] } };
}
map. on ( 'load' , () => {
map. addSource ( 'zone' , { type: 'geojson' , data: fuzzyCircle ([ 2.3522 , 48.8566 ], 0.5 ) });
map. addLayer ({ id: 'zone-fill' , type: 'fill' , source: 'zone' ,
paint: { 'fill-color' : '#9C27B0' , 'fill-opacity' : 0.2 } });
map. addLayer ({ id: 'zone-border' , type: 'line' , source: 'zone' ,
paint: { 'line-color' : '#9C27B0' , 'line-width' : 2 , 'line-dasharray' : [ 4 , 2 ] } });
}); 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: 13
});
function fuzzyCircle ( center , radiusKm , points = 64 ) {
const coords = [];
for ( let i = 0 ; i <= points; i ++ ) {
const angle = (i / points) * 2 * Math. PI ;
const dx = radiusKm / ( 111.32 * Math. cos (center[ 1 ] * Math. PI / 180 ));
const dy = radiusKm / 110.574 ;
coords. push ([center[ 0 ] + dx * Math. cos (angle), center[ 1 ] + dy * Math. sin (angle)]);
}
return { type: 'Feature' , geometry: { type: 'Polygon' , coordinates: [coords] } };
}
map. on ( 'load' , () => {
map. addSource ( 'zone' , { type: 'geojson' , data: fuzzyCircle ([ 2.3522 , 48.8566 ], 0.5 ) });
map. addLayer ({ id: 'zone-fill' , type: 'fill' , source: 'zone' ,
paint: { 'fill-color' : '#9C27B0' , 'fill-opacity' : 0.2 } });
map. addLayer ({ id: 'zone-border' , type: 'line' , source: 'zone' ,
paint: { 'line-color' : '#9C27B0' , 'line-width' : 2 , 'line-dasharray' : [ 4 , 2 ] } });
});
</ 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: 13
});
function fuzzyCircle ( center , radiusKm , points = 64 ) {
const coords = [];
for ( let i = 0 ; i <= points; i ++ ) {
const angle = (i / points) * 2 * Math. PI ;
const dx = radiusKm / ( 111.32 * Math. cos (center[ 1 ] * Math. PI / 180 ));
const dy = radiusKm / 110.574 ;
coords. push ([center[ 0 ] + dx * Math. cos (angle), center[ 1 ] + dy * Math. sin (angle)]);
}
return { type: 'Feature' , geometry: { type: 'Polygon' , coordinates: [coords] } };
}
map. on ( 'load' , () => {
map. addSource ( 'zone' , { type: 'geojson' , data: fuzzyCircle ([ 2.3522 , 48.8566 ], 0.5 ) });
map. addLayer ({ id: 'zone-fill' , type: 'fill' , source: 'zone' ,
paint: { 'fill-color' : '#9C27B0' , 'fill-opacity' : 0.2 } });
map. addLayer ({ id: 'zone-border' , type: 'line' , source: 'zone' ,
paint: { 'line-color' : '#9C27B0' , 'line-width' : 2 , 'line-dasharray' : [ 4 , 2 ] } });
});
maptilersdk.config.apiKey = 'YOUR_MAPTILER_KEY';
const map = new maptilersdk.Map({
container: 'map',
style: maptilersdk.MapStyle.STREETS,
center: [2.3522, 48.8566],
zoom: 13
});
function fuzzyCircle(center, radiusKm, points = 64) {
const coords = [];
for (let i = 0; i <= points; i++) {
const angle = (i / points) * 2 * Math.PI;
const dx = radiusKm / (111.32 * Math.cos(center[1] * Math.PI / 180));
const dy = radiusKm / 110.574;
coords.push([center[0] + dx * Math.cos(angle), center[1] + dy * Math.sin(angle)]);
}
return { type: 'Feature', geometry: { type: 'Polygon', coordinates: [coords] } };
}
map.on('load', () => {
map.addSource('zone', { type: 'geojson', data: fuzzyCircle([2.3522, 48.8566], 0.5) });
map.addLayer({ id: 'zone-fill', type: 'fill', source: 'zone',
paint: { 'fill-color': '#9C27B0', 'fill-opacity': 0.2 } });
map.addLayer({ id: 'zone-border', type: 'line', source: 'zone',
paint: { 'line-color': '#9C27B0', 'line-width': 2, 'line-dasharray': [4, 2] } });
}); <!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: 13
});
function fuzzyCircle(center, radiusKm, points = 64) {
const coords = [];
for (let i = 0; i <= points; i++) {
const angle = (i / points) * 2 * Math.PI;
const dx = radiusKm / (111.32 * Math.cos(center[1] * Math.PI / 180));
const dy = radiusKm / 110.574;
coords.push([center[0] + dx * Math.cos(angle), center[1] + dy * Math.sin(angle)]);
}
return { type: 'Feature', geometry: { type: 'Polygon', coordinates: [coords] } };
}
map.on('load', () => {
map.addSource('zone', { type: 'geojson', data: fuzzyCircle([2.3522, 48.8566], 0.5) });
map.addLayer({ id: 'zone-fill', type: 'fill', source: 'zone',
paint: { 'fill-color': '#9C27B0', 'fill-opacity': 0.2 } });
map.addLayer({ id: 'zone-border', type: 'line', source: 'zone',
paint: { 'line-color': '#9C27B0', 'line-width': 2, 'line-dasharray': [4, 2] } });
});
</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: 13
});
function fuzzyCircle(center, radiusKm, points = 64) {
const coords = [];
for (let i = 0; i <= points; i++) {
const angle = (i / points) * 2 * Math.PI;
const dx = radiusKm / (111.32 * Math.cos(center[1] * Math.PI / 180));
const dy = radiusKm / 110.574;
coords.push([center[0] + dx * Math.cos(angle), center[1] + dy * Math.sin(angle)]);
}
return { type: 'Feature', geometry: { type: 'Polygon', coordinates: [coords] } };
}
map.on('load', () => {
map.addSource('zone', { type: 'geojson', data: fuzzyCircle([2.3522, 48.8566], 0.5) });
map.addLayer({ id: 'zone-fill', type: 'fill', source: 'zone',
paint: { 'fill-color': '#9C27B0', 'fill-opacity': 0.2 } });
map.addLayer({ id: 'zone-border', type: 'line', source: 'zone',
paint: { 'line-color': '#9C27B0', 'line-width': 2, 'line-dasharray': [4, 2] } });
});