-
Notifications
You must be signed in to change notification settings - Fork 173
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
Using crs.scale with zoom level bigger than maxZoom does not throw errors #144
Comments
Hi and thanks for this detailed writeup! It looks pretty clear what the problem is, but it's less clear what It sounds like this is a duplicate of #82, so solving this could close both. |
Hi, :) Yep, not sure about that too. For me the main issue was that I did not specify the The problems this causes sound quite the same, not sure if the actual cause is the same though. P.S. Just did a check on this in |
Hi again and sorry for a very late reply! Some thoughts on this: the issue, like you said initially, is that Leaflet will sometimes need resolution/scale for zoom levels outside the A workaround is definitely to define resolution of extra zoom levels outside the intervals, like you did. Ideally, we'd want a way to fix this more properly without having to understand why they would need a workaround like this. I don't have a real plan here, I'm typing this out more like a brain dump. For most maps, the way we explicitly specify resolutions or scales is tedious and unnecessary, since there is a fixed factor between each zoom level, typically 2, just like Leaflet's default projection. We could do away with the array of fixed resolutions all together and just specify the resolution/scale for one zoom level together with the factor. This way we could calculate the scale for any zoom level - this would mean simpler configuration and solving this issue. We could also use this as a fallback for maps which specify the scales/resolutions like today as well: use the specified resolutions inside the defined zoom levels, but fall back to calculating using a default factor when outside the array. While not entirely fool proof, I think this would at least work better than what we have now. |
I have come up against this issue, again when trying to create maps based on the Ordnance Survey maps API using a tile set in EPSG:27700. This defines a minimum zoom level of zero with a resolution of 896.0. At this resolution it is difficult to create a map which shows the whole country of Great Britain, clearly a common thing to want to do. So we need to use negative zoom levels, and due to this bug proj4leaflet doesn't allow it. As suggested in the above comment the solution in this instance is as simple as changing part of the |
When using
Leaflet
and at some pointcrs.scale
function is called with a zoom level bigger thanmaxZoom
that executes this part of the code https://github.com/kartena/Proj4Leaflet/blob/master/src/proj4leaflet.js#L111 from this line https://github.com/kartena/Proj4Leaflet/blob/master/src/proj4leaflet.js#L118 we will haveundefined
returned if theresolutions
does not have this zoom level defined.Then
Leaflet
will work with theundefined
and at some point[NaN, NaN]
will be passed into this function https://github.com/kartena/Proj4Leaflet/blob/master/src/proj4leaflet.js#L38 forproj4js
to handle withinverse
function. Sinceproj4js
does no handle[NaN, NaN]
input consistently (does not always return[NaN, NaN]
, could return completely normal result as[0, 90]
) this will result in different issues.One of the issues will be cause by this line https://github.com/kartena/Proj4Leaflet/blob/master/src/proj4leaflet.js#L40 to throw the
Invalid LatLng object
message.This is in part a problem with
proj4js
and I have filed an issue there proj4js/proj4js#250, but also maybeproj4leaflet
could show a warning or throw an error if https://github.com/kartena/Proj4Leaflet/blob/master/src/proj4leaflet.js#L118 returnsundefined
?The text was updated successfully, but these errors were encountered: