code
Snippet
language
CDN
package_2
NPM
content_copy
Copy
open_in_new
Open
maptilersdk.config.apiKey = 'YOUR_MAPTILER_KEY' ;
const map = new maptilersdk. Map ({
container: 'map' ,
style: maptilersdk.MapStyle. STREETS ,
center: [ 78 , 30 ],
zoom: 4
});
window. showBorders = function ( countryCode ) {
const style = map. getStyle ();
style.layers. forEach ( function ( layer ) {
if (layer.id. includes ( 'boundary' ) || layer.id. includes ( 'border' )) {
if (layer[ 'source-layer' ] === 'boundary' ) {
if (countryCode) {
map. setFilter (layer.id, [ 'any' ,
[ '!' , [ 'has' , 'disputed' ]],
[ '==' , [ 'get' , 'disputed' ], 0 ],
[ '==' , [ 'get' , 'claimed_by' ], countryCode]
]);
} else {
map. setFilter (layer.id, null );
}
}
}
});
}; content_copy
Copy
open_in_new
Open
<! doctype html >
< html lang = "en" >
< head >
< meta charset = "utf-8" >
< meta name = "viewport" content = "width=device-width, initial-scale=1.0" >
< title >Disputed Borders View with MapTiler SDK</ title >
< link rel = "stylesheet" href = "https://cdn.maptiler.com/maptiler-sdk-js/v4.2.0/maptiler-sdk.css" >
< script src = "https://cdn.maptiler.com/maptiler-sdk-js/v4.2.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 >
< div style = "position:absolute;top:10px;left:10px;z-index:1;display:flex;gap:3px;flex-wrap:wrap;" >
< button onclick = " showBorders ('')" style = "padding:5px 10px;background:#141414;color:#e0e0e0;border:2px solid #2a2a2a;font-family:monospace;font-size:11px;font-weight:600;cursor:pointer;" >Default</ button >
< button onclick = " showBorders ('IN')" style = "padding:5px 10px;background:#141414;color:#e0e0e0;border:2px solid #2a2a2a;font-family:monospace;font-size:11px;font-weight:600;cursor:pointer;" >India</ button >
< button onclick = " showBorders ('CN')" style = "padding:5px 10px;background:#141414;color:#e0e0e0;border:2px solid #2a2a2a;font-family:monospace;font-size:11px;font-weight:600;cursor:pointer;" >China</ button >
< button onclick = " showBorders ('PK')" style = "padding:5px 10px;background:#141414;color:#e0e0e0;border:2px solid #2a2a2a;font-family:monospace;font-size:11px;font-weight:600;cursor:pointer;" >Pakistan</ button >
</ div >
< script >
maptilersdk.config.apiKey = 'YOUR_MAPTILER_KEY' ;
const map = new maptilersdk. Map ({
container: 'map' ,
style: maptilersdk.MapStyle. STREETS ,
center: [ 78 , 30 ],
zoom: 4
});
window. showBorders = function ( countryCode ) {
const style = map. getStyle ();
style.layers. forEach ( function ( layer ) {
if (layer.id. includes ( 'boundary' ) || layer.id. includes ( 'border' )) {
if (layer[ 'source-layer' ] === 'boundary' ) {
if (countryCode) {
map. setFilter (layer.id, [ 'any' ,
[ '!' , [ 'has' , 'disputed' ]],
[ '==' , [ 'get' , 'disputed' ], 0 ],
[ '==' , [ 'get' , 'claimed_by' ], countryCode]
]);
} else {
map. setFilter (layer.id, null );
}
}
}
});
};
</ script >
</ body >
</ html > content_copy
Copy
open_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: [ 78 , 30 ],
zoom: 4
});
window. showBorders = function ( countryCode ) {
const style = map. getStyle ();
style.layers. forEach ( function ( layer ) {
if (layer.id. includes ( 'boundary' ) || layer.id. includes ( 'border' )) {
if (layer[ 'source-layer' ] === 'boundary' ) {
if (countryCode) {
map. setFilter (layer.id, [ 'any' ,
[ '!' , [ 'has' , 'disputed' ]],
[ '==' , [ 'get' , 'disputed' ], 0 ],
[ '==' , [ 'get' , 'claimed_by' ], countryCode]
]);
} else {
map. setFilter (layer.id, null );
}
}
}
});
};
maptilersdk.config.apiKey = 'YOUR_MAPTILER_KEY';
const map = new maptilersdk.Map({
container: 'map',
style: maptilersdk.MapStyle.STREETS,
center: [78, 30],
zoom: 4
});
window.showBorders = function(countryCode) {
const style = map.getStyle();
style.layers.forEach(function(layer) {
if (layer.id.includes('boundary') || layer.id.includes('border')) {
if (layer['source-layer'] === 'boundary') {
if (countryCode) {
map.setFilter(layer.id, ['any',
['!', ['has', 'disputed']],
['==', ['get', 'disputed'], 0],
['==', ['get', 'claimed_by'], countryCode]
]);
} else {
map.setFilter(layer.id, null);
}
}
}
});
}; <!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Disputed Borders View with MapTiler SDK</title>
<link rel="stylesheet" href="https://cdn.maptiler.com/maptiler-sdk-js/v4.2.0/maptiler-sdk.css">
<script src="https://cdn.maptiler.com/maptiler-sdk-js/v4.2.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>
<div style="position:absolute;top:10px;left:10px;z-index:1;display:flex;gap:3px;flex-wrap:wrap;">
<button onclick="showBorders('')" style="padding:5px 10px;background:#141414;color:#e0e0e0;border:2px solid #2a2a2a;font-family:monospace;font-size:11px;font-weight:600;cursor:pointer;">Default</button>
<button onclick="showBorders('IN')" style="padding:5px 10px;background:#141414;color:#e0e0e0;border:2px solid #2a2a2a;font-family:monospace;font-size:11px;font-weight:600;cursor:pointer;">India</button>
<button onclick="showBorders('CN')" style="padding:5px 10px;background:#141414;color:#e0e0e0;border:2px solid #2a2a2a;font-family:monospace;font-size:11px;font-weight:600;cursor:pointer;">China</button>
<button onclick="showBorders('PK')" style="padding:5px 10px;background:#141414;color:#e0e0e0;border:2px solid #2a2a2a;font-family:monospace;font-size:11px;font-weight:600;cursor:pointer;">Pakistan</button>
</div>
<script>
maptilersdk.config.apiKey = 'YOUR_MAPTILER_KEY';
const map = new maptilersdk.Map({
container: 'map',
style: maptilersdk.MapStyle.STREETS,
center: [78, 30],
zoom: 4
});
window.showBorders = function(countryCode) {
const style = map.getStyle();
style.layers.forEach(function(layer) {
if (layer.id.includes('boundary') || layer.id.includes('border')) {
if (layer['source-layer'] === 'boundary') {
if (countryCode) {
map.setFilter(layer.id, ['any',
['!', ['has', 'disputed']],
['==', ['get', 'disputed'], 0],
['==', ['get', 'claimed_by'], countryCode]
]);
} else {
map.setFilter(layer.id, null);
}
}
}
});
};
</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: [78, 30],
zoom: 4
});
window.showBorders = function(countryCode) {
const style = map.getStyle();
style.layers.forEach(function(layer) {
if (layer.id.includes('boundary') || layer.id.includes('border')) {
if (layer['source-layer'] === 'boundary') {
if (countryCode) {
map.setFilter(layer.id, ['any',
['!', ['has', 'disputed']],
['==', ['get', 'disputed'], 0],
['==', ['get', 'claimed_by'], countryCode]
]);
} else {
map.setFilter(layer.id, null);
}
}
}
});
};
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Disputed Borders View with MapTiler SDK</title>
<link rel="stylesheet" href="https://cdn.maptiler.com/maptiler-sdk-js/v4.2.0/maptiler-sdk.css">
<script src="https://cdn.maptiler.com/maptiler-sdk-js/v4.2.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>
<div style="position:absolute;top:10px;left:10px;z-index:1;display:flex;gap:3px;flex-wrap:wrap;">
<button onclick="showBorders('')" style="padding:5px 10px;background:#141414;color:#e0e0e0;border:2px solid #2a2a2a;font-family:monospace;font-size:11px;font-weight:600;cursor:pointer;">Default</button>
<button onclick="showBorders('IN')" style="padding:5px 10px;background:#141414;color:#e0e0e0;border:2px solid #2a2a2a;font-family:monospace;font-size:11px;font-weight:600;cursor:pointer;">India</button>
<button onclick="showBorders('CN')" style="padding:5px 10px;background:#141414;color:#e0e0e0;border:2px solid #2a2a2a;font-family:monospace;font-size:11px;font-weight:600;cursor:pointer;">China</button>
<button onclick="showBorders('PK')" style="padding:5px 10px;background:#141414;color:#e0e0e0;border:2px solid #2a2a2a;font-family:monospace;font-size:11px;font-weight:600;cursor:pointer;">Pakistan</button>
</div>
<script>
maptilersdk.config.apiKey = 'LKv9WPh4aJggV1CHU4Y8';
const map = new maptilersdk.Map({
container: 'map',
style: maptilersdk.MapStyle.STREETS,
center: [78, 30],
zoom: 4
});
window.showBorders = function(countryCode) {
const style = map.getStyle();
style.layers.forEach(function(layer) {
if (layer.id.includes('boundary') || layer.id.includes('border')) {
if (layer['source-layer'] === 'boundary') {
if (countryCode) {
map.setFilter(layer.id, ['any',
['!', ['has', 'disputed']],
['==', ['get', 'disputed'], 0],
['==', ['get', 'claimed_by'], countryCode]
]);
} else {
map.setFilter(layer.id, null);
}
}
}
});
};
</script>
</body>
</html>