Skip to content

Conversation

perliedman
Copy link
Member

This moves the parts hardcoded for spherical Mercator from L.TileLayer into L.CRS, where they can be overridden more easily.

In particular, this makes it possible to use TMS with L.TileLayer with projections other than spherical Mercator, which isn't possible today. (Proj4Leaflet currently has a pretty nasty workaround for this, which would be nice to get rid off.)

To do this, the method getSize is added to ICRS, which returns the size of the entire CRS in pixels, for a given zoom level. This is in turn used in L.TileLayer to calculate the the proper tile number for wrapping and TMS.

_getWrapTileNum: function () {
// TODO refactor, limit is not valid for non-standard projections
return Math.pow(2, this._getZoomForUrl());
_getWrapTileNum: function () {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please fix whitespace here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, sorry. Fixed.

@mourner
Copy link
Member

mourner commented Nov 6, 2013

That's a really nice way to remove the hardcode! I'll merge this for 0.7.

mourner added a commit that referenced this pull request Nov 6, 2013
Remove hardcoded world size from L.TileLayer
@mourner mourner merged commit e2977a1 into Leaflet:master Nov 6, 2013
mourner added a commit that referenced this pull request Nov 6, 2013
@mourner
Copy link
Member

mourner commented Nov 6, 2013

Patched up _tilesShouldBeLoaded as well, be careful next time :)

@perliedman perliedman deleted the crs-size branch November 6, 2013 22:29
@perliedman
Copy link
Member Author

Yes, sorry!

@mourner
Copy link
Member

mourner commented Nov 6, 2013

No problem, thanks a lot for the pull :) Feel free to check out other projection-related hardcodes in Leaflet codebase or any ways to improve the projections code and send suggestions/pull requests.

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

Successfully merging this pull request may close these issues.

2 participants