Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updating tileSize on zoom #6966

Closed
CallMarl opened this issue Jan 9, 2020 · 3 comments
Closed

updating tileSize on zoom #6966

CallMarl opened this issue Jan 9, 2020 · 3 comments

Comments

@CallMarl
Copy link

CallMarl commented Jan 9, 2020

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.

@anthony-bt
Copy link

anthony-bt commented Jan 19, 2020

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.

@IvanSanchez
Copy link
Member

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.

@IvanSanchez
Copy link
Member

You're probably looking for maxNativeZoom BTW.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants