TransWikia.com

OpenLayers: How to shift zoom level content for ol/sourceXYZ about one zoom level

Geographic Information Systems Asked by Günter Schmudlach on July 19, 2021

The Swisstopo WMTS service assigns specific raster map content to specific zoom levels:

  • ….
  • 16: 1:25’000 Raster map
  • 15: 1:50’000 Raster map
  • 14: 1:100’000 Raster map
  • ….

Here is a code example.

Compared to other map source the result is an extremely inflated map content. Just compare the font size of text contained in these maps: Swisstopo to IGN.

How can I load the Swisstopo ol/sourceXYZ by shifting the content about one zoom level? The result would be then:

  • ….
  • 17: 1:25’000
  • 16: 1:50’000
  • 15: 1:100’000
  • ….

One Answer

You cannot change the fixed content of what is served, but you could set up OpenLayers to treat the 256 pixel tiles served as if they were hidpi 128 pixel tiles

  url: 'https://wmts10.geo.admin.ch/1.0.0/' + layername + '/default/' + timestamp + '/3857/{z}/{x}/{y}.jpeg',
  tileSize: 128,
  tilePixelRatio: 2

The zoom level requested for any view resolution would then be offset by 1 (but you would be requesting 4 times as many tiles) https://codepen.io/mike-000/pen/NWdZELE?editors=0010

Correct answer by Mike on July 19, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP