3
votes

I have a geojson representing contour layers of interpolated weather data. Certain contours disappear at higher zoom levels as seen in following screengrab. Layer disappears on higher zoom

When adding the multipolygon to Mapbox as a layer, using the following code:

map.addSource('mintempContour', {
        type: 'geojson',
        data: geojson_source
        });

        map.addLayer({
            "id": 'mintemp',
            "type": "fill",
            "minzoom": 2,
            "maxzoom": 15,
            "source": "mintempContour",
            "layout": {
                'visibility': 'visible'
            },
            "paint": {
                "fill-color": { type: 'identity', property: 'fill' },
                "fill-opacity": 1

            }

            //"filter": ["==", "$type", "Polygon"]
        }, 'water');

I have tested the geojson file on sites like geojson.io and the contours remain visible at all zoom levels.

I want all contours to be present all the time, regardless of the zoom level. How can I fix this?

Quick and dirty JSFiddle replicating issue: https://jsfiddle.net/stefmarais/ae9nzmrt/12/

1

1 Answers

1
votes

You are setting maxZoom when calling addLayer, which according to the docs does:

The maximum zoom level for the layer. At zoom levels equal to or greater than the maxzoom, the layer will be hidden. https://docs.mapbox.com/mapbox-gl-js/style-spec/#layer-maxzoom

I think you actually want to set maxzoom on the source, not the layer:

Maximum zoom level at which to create vector tiles (higher means greater detail at high zoom levels). https://docs.mapbox.com/mapbox-gl-js/style-spec/#sources-geojson-maxzoom

(or just none at all).