MapSnippets logo MapSnippets logo

Disputed Borders View with MapTiler SDK

MapTiler SDK

Filter disputed boundary lines in MapTiler SDK by calling map.setFilter() on boundary layers with the claimed_by property for a chosen country's view.

progress_activity Loading 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 to show disputed borders for a country’s view with MapTiler SDK

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. Each view is stored as a separate feature with its own claimed_by value.

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 with the ISO2 code of the claiming country docs.maptiler.com/guides
disputed Vector tile property, 1 if the 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), while 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])

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.