Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mapbox GL JS : JSON points disappear

I have JSON icons on my map and they disappear as I zoom out from them when they are close together. (I am guessing to avoid cluttering). I would like to keep them though - even if they somehow overlap - as these icons are used for analysis. I can't find documentation to avoid this. Below is an example screenshot - and my code to display the JSON points.

Screenshot :

enter image description here

Current code (entire function as there is not much to it - simple):

function addMDA_toA(){

    topleftmapbox.loadImage('images/MDA.png', function(error, image) {
        if (error) throw error;
        topleftmapbox.addImage('meso-image', image);

    });


     var url = 'json/MDA.json';



    window.setInterval(function() {
        topleftmapbox.getSource('mesocyclone').setData(url);
    }, 2000);

    topleftmapbox.addSource('mesocyclone', { type: 'geojson', data: url });
    topleftmapbox.addLayer({
        "id": "mesocyclone",
        "type": "symbol",
        "source": "mesocyclone",
        "layout": {
            "icon-image": "meso-image"
        }
    });

}
like image 672
David Avatar asked Sep 20 '25 18:09

David


1 Answers

When adding the layer, the following layout attributes must be true:

     "icon-allow-overlap" : true,
     "text-allow-overlap": true

Without both of these set to true, the issue will not be resolved.

like image 162
David Avatar answered Sep 22 '25 07:09

David