MapSnippets logoMapSnippets logo

Disputed Borders View with MapTiler SDK

MapTiler SDK

Show country-specific border representations by filtering disputed boundary layers based on the claimed_by property.

progress_activityLoading map...
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);
        }
      }
    }
  });
};

How it works

MapTiler vector tiles include boundary features with special properties for disputed territories. The disputed property marks a border as contested, and claimed_by contains the ISO 3166-1 alpha-2 country code of the claiming nation.

To show borders from a specific country’s perspective, iterate through all boundary layers and set a filter that shows undisputed borders plus disputed borders claimed by the target country. Setting the filter to null restores the default view.

This approach works because MapTiler Planet tiles encode territorial claims as feature properties in the boundary source layer. Countries like India, China, and Pakistan each have different legal views of Kashmir’s borders, and these are represented as separate features with different claimed_by values.

Key APIs

API Description Docs
map.getStyle() Get the current style object with all layers docs.maptiler.com/sdk-js/api/
map.setFilter() Set a filter expression on a layer docs.maptiler.com/sdk-js/api/
claimed_by Vector tile property: ISO2 code of claiming country docs.maptiler.com/guides
disputed Vector tile property: 1 if border is disputed docs.maptiler.com/guides

FAQ

Which country perspectives are available?

MapTiler supports viewpoints from 30+ countries including India (IN), China (CN), Pakistan (PK), Russia (RU), Ukraine (UA), Israel (IL), Palestine (PS), Turkey (TR), and others. See the MapTiler disputed borders guide for the full list.

Can I configure this in the Map Designer instead?

Yes. In MapTiler Cloud, customize a map copy and select “Preferred country borders” in the Settings panel. This embeds the filters in the style itself.

Common mistakes

  • Filtering on the wrong source-layer: disputed properties are on the boundary source-layer, not on labels or fills
  • Using lowercase country codes (in): the claimed_by property uses uppercase ISO2 codes (IN)
  • Forgetting that the filter removes the default view: always include a condition for undisputed borders (['!', ['has', 'disputed']] or ['==', ['get', 'disputed'], 0])
auto_awesome

Build maps using MapTiler SDK with AI

Generate code like this disputed borders view with maptiler sdk example using the MapTiler SDK skill in your IDE.