I am using OpenLayers to create a map. The base of the map is being created using XYZ as the source. I only have till certain zoom level and i was wondering if there is any way to make the browser stop requesting more tiles after a certain zoom level.

GET http://localhost:4200/assets/tile/14/5/3.png 404 (Not Found)

1 Answer 1


ol.source.XYZ has a maxZoom option

source: new ol.source.XYZ({
  url: 'http://localhost:4200/assets/tile/{z}/{x}/{y}.png',
  maxZoom: 13
  • This does not allow the user to zoom more than 13, i want the user to be able to zoom on the last received tiles. Commented Sep 19, 2019 at 8:33
  • It doesn't restrict view zoom. If you don't have tiles at level 14 you would need to let OpenLayers browser zoom a level which does exist.
    – Mike
    Commented Sep 19, 2019 at 8:37
  • I tried this, it does not work Commented Sep 19, 2019 at 8:54
  • It is working here codepen.io/mike-000/pen/WNeaVeq The view is zoomed to level 15 even though tiles are restricted to level 13.,
    – Mike
    Commented Sep 19, 2019 at 9:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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