Leaflet: updating tileSize on zoom

Created on 9 Jan 2020  路  3Comments  路  Source: Leaflet/Leaflet

Hello,

I'm very beginner in JS and also leaflet library. I would like to if something existe to change how the zoom works. Is there a class or feature that enable to change the tileSize on zoom.

Thank you.

Most helpful comment

Hi, great to hear that you find Leaflet useful!

However, this issue tracker is used for reporting bugs and discussing new features. For questions on using Leaflet, please use gis.stackexchange.com or stackoverflow.

If you are really sure that this is a bug in leaflet, or a feature request, please change the wording to make it look like a bug report.

All 3 comments

Hi @CallMarl, I don't know if I understand well your problem but you can change your base layer used at the beginning on zoom events. So you could switch your layer with another configured as you want.

You need:

import * as L from 'leaflet';

// map config
const mapUrl = 'YOUR_URL';
const baseLayer = L.tileLayer(mapUrl, { maxZoom: 20 });
const newMapUrl = 'YOUR_NEW_URL';
const newBaseLayer = L.tileLayer(newMapUrl, { maxZoom: 20 });

// init map
this.map = L.map('map', {
  center: new L.LatLng(48.84195331838587, 2.2852662205696106),
  zoom: 18,
  layers: [baseLayer]
});

// zoom event
this.map.on('zoomend', () => {
  this.map.removeLayer(baseLayer);
  this.map.addLayer(newBaseLayer);
});

I hope it could help you.

Hi, great to hear that you find Leaflet useful!

However, this issue tracker is used for reporting bugs and discussing new features. For questions on using Leaflet, please use gis.stackexchange.com or stackoverflow.

If you are really sure that this is a bug in leaflet, or a feature request, please change the wording to make it look like a bug report.

You're probably looking for maxNativeZoom BTW.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

onethread picture onethread  路  3Comments

timwis picture timwis  路  3Comments

remilev picture remilev  路  4Comments

zdila picture zdila  路  3Comments

viswaug picture viswaug  路  4Comments