Azure maps - Removing country borders from map

355 views Asked by At

I'm using an Azure map in react-typescript, where I show the provinces of Belgium by adding a polygon layer. The country borders from my polygon-provinces are more detailed than the default country borders drawn by Azure maps. How can I remove the 'Azure borders' from my map?

1

There are 1 answers

4
rbrundritt On

Custom styling isn't currently supported, however here is an undocumented/unsupported way to achieve this today.

map.events.add('ready', function () {
    //Remove borders on initial load. 
    removeBorders();
});

//Remove borders when the map style changes.
map.events.add('styledata', removeBorders);

function removeBorders() {
    var layers = map.map.getStyle().layers;

    for (var i = 0; i < layers.length; i++) {
        switch (layers[i]['source-layer']) {
            //Country borders
            case 'Country border':
            case 'Disputed country border':

            //State/province borders
            case 'State border':
                map.map.setLayoutProperty(layers[i].id, 'visibility', 'none');
                break;
        }
    }
}