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

If neither resolutions nor scales are defined in the constructor, then should use parent methods #175

Open
scaddenp opened this issue May 15, 2020 · 4 comments

Comments

@scaddenp
Copy link

The L.CRS.scale and zoom function depend on _scales array. If neither scales nor resoltions defined in the constructor, then it fails. I believe it use parent (L.CRS) methods when _scales is not defined.

@perliedman
Copy link
Contributor

Hi, I think it might actually be better to throw an error when constructing the CRS without scales or resolutions, since it is highly unlikely the default scale calculation will work - it is pretty closely tied to the way spherical Mercator works in Leaflet, IIRC.

@scaddenp
Copy link
Author

Hmm. I ran into it with a custom version of world mercator (Pacific-centric custom version without the antimeridian hassles). No resolutions information available from tiler. Not sure how you would specify scales and resolution to imitate the default calculation. How about possibility of passing scale and resolution functions in? ie options of scaleFunction, resolutionFunction. Or maybe just option of "useMercatorScales". If true, then inherit functions from L.CRS since they are the most likely functions to use.

@perliedman
Copy link
Contributor

Sorry for the delay, don't have much time for open source maintenance these days.

I would go with allowing scale/resolution to be either an array or a function, I think it is a quite common pattern in the JavaScript world, and I seem to remember even Leaflet using it for some options. That would allow a lot of flexibility!

@scaddenp
Copy link
Author

scaddenp commented Jun 1, 2020

Yes, I agree. That is an excellent suggestion. Maximum flexibility.

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

2 participants