User:SomeoneElse/Tileserver zoom levels

From OpenStreetMap Wiki
Jump to: navigation, search

Apologies in advance to anyone who finds what follows "the bleedin' obvious" - it wasn't to me, which is why I'm gathering the information together on one page.

If you set up a tile server using the instructions at e.g. switch2osm [1] and [2] you'll get a tile server that can zoom between levels 0 and 18 - 18 is just the default maximum. However, it's possible to render higher zooms without too much difficulty. On this page I'll go through the changes needed to change the value to 20. The maximum zoom level is defined in a few places:

In render_config.h

If you've installed manually, that'll probably be somewhere like:


In there it is already:

#define MAX_ZOOM 20

so the chances are you don't want to change that. Note that changing the zoom level to above 20 requires a change to the metatile storage path, so it's not a change to be undertaken lightly. See [3] for that.

In renderd.conf

This file will probably be somewhere like /usr/local/etc/renderd.conf, and may already have a value commented out. If so, uncomment it and set to the correct value. I've added the entry for the layer that I want to set it before, after the "FILESIZE" line:


Note that there's no underscore here, and there was in render_config.h . Restart renderd after changing:

sudo /etc/init.d/renderd restart

In openstreetmap-tiles-update-expire

If the database is being updated using minutely or hourly diffs then "openstreetmap-tiles-update-expire" will be being used to rerender, delete or dirty expired tiles. The zoom levels in there will need to be modified as required. is an example version that rerenders expired tiles at zoom levels 13 through 17, and deletes those at 18-20. The default actions and the actual zoom levels at which they occur can be changed as required.

In the Leaflet "L.TileLayer" parameter

Exactly where this is depends on your website, but if using Leaflet somewhere there'll be a line that's something like:

   var mynameLayer = new L.TileLayer( mynameUrl, {minZoom: 0, maxZoom: 19, maxNativeZoom: 18, attribution: osmAttrib });

That means "create a tile layer using mynameUrl as the URL, and support zoom levels 0 to 19, with 19 being 'overzoomed' layer 18 tiles". To change to zoom level 20 it really is as simple as:

   var mynameLayer = new L.TileLayer( mynameUrl, {minZoom: 0, maxZoom: 20, maxNativeZoom: 20, attribution: osmAttrib });

Other changes

After making these changes you may want to change the underlying rendering - making road widths wider at z19 and z20, and perhaps making text sizes larger. Over at [4] I've done both of these.

See also

It's also possible to control which layers get automatically rerendered when data changes. See [5] for that.