2

i found in this post:
CartoCSS layer visibility
a solution to set a layer not visible for some zoom levels.

But in
https://github.com/gravitystorm/openstreetmap-carto
it seems that a minzoom parameter can be set (according to the project.mml file) :

   {
      "name": "coast-poly",
      "srs-name": "900913",
      "geometry": "polygon",
      "class": "",
      "id": "coast-poly",
      "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over",
      "Datasource": {
        "type": "shape",
        "file": "data/land-polygons-split-3857/land_polygons.shp"
      },
      "extent": [
        -180,
        -85.05112877980659,
        180,
        85.05112877980659
      ],
      **"properties": {
        "minzoom": 10
      },**
      "advanced": {}
    },

But in Tilemill i can't get it working (lines are drawn in red).

What would be the best/fastest solution to manage minzoom & maxzoom for layers in TileMill?

My TileMill output could be Mbtiles or Mapnik files. Does this output strategy have an impact on the solution?

1

Assuming that you have, for example, a layer with the ID rivers.

You could select each zoom level that the layer should be displayed at individually:

#rivers[zoom=4],[zoom=5],[zoom=6] {
 ...
}

This would display the dataset only at zoom levels 4, 5, and 6.

Or, and I think this is more what you were looking for, you can use a greater than:

#rivers[zoom>4] {
 ...
}

This would apply the rules to any zoom level greater than 4.

Note that you can also use greater or equal:

#rivers[zoom>=4]{
 ...
}

The important thing to know in CartoCSS is that if there are no rules defined a dataset will not be displayed. So if you only define rules for greater or equal than 4, then 4 will translate to the layer's minimum zoom, and levels 1, 2, and 3 will not be shown.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.