-
-
Notifications
You must be signed in to change notification settings - Fork 6k
Major TileLayer + projections refactoring #2247
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
Conversation
|
Needs some history cleanup with interactive rebase, will do... |
|
Have taken a read through. Seems good so far! |
|
@perliedman had to do some modifications to EPSG:4326 to make the WMS Marble example work and also fix #1207. Could you verify that please? |
|
@perliedman awesome. Could you look at what would be required for Proj4Leaflet to reflect those changes? |
|
@tmcw @jfirebaugh this is pretty much ready for review, only minor stuff left to do. |
|
@mourner I will try to find time in the next couple of days. Mostly removing stuff I guess. |
|
@perliedman awesome! |
|
Copying what I said in IRC: Final issue for the projections refactoring is how LatLng wrapping should be done. We need to move this from |
|
The idea to move wrapping is to handle the flat/other world's scenario, right? I think it depends on just how weird those other world's might be.
I'm leaning against the first, in |
|
@perliedman yeah, I agree that esoteric CRS which would have trouble with wrapping don't need it anyway, so I'm inclined to go with a simpler method. The only issue is that wrapping by unprojecting, wrapping and projecting again seems a bit complex, so I thought we could simplify that by wrapping LatLng directly using LatLng values derived from Projection bounds. |
|
Oh. Yes, that makes sense. |
|
OK, now the refactoring looks pretty good and feature-complete. The only thing left before merge is to cover all that goodness with more tests. |
|
Cleaned up and rebased, can be cleanly merged into master now. |
|
@sheppard @pthorin @leplatrem @calvinmetcalf @turban @moonlite guys, you're welcome to review this as well — let me know what you think. |
|
All the projections stuff in Leaflet FINALLY makes complete sense to me after years of "I'll figure this out later" thinking. Big thanks to @perliedman (Proj4Leaflet maintainer) for all the help. |
|
This will be a great improvement for anyone not using the already builtin projections. Also lots less to maintain in Proj4Leaflet :) Happy that I could help! |
|
This looks great! Great work! |
|
I feel honored you asked me :) And I guess there is a chance it fixes an inexplicable bug we had on Proj4Leaflet kartena/Proj4Leaflet#37 |
|
This seems fantastic, still looking through the code, but so far, ❤️ |
|
Looks promising! I would like to use Leaflet with a Lambert Azimuthal Equal Area Projection (image), but I'm having trouble when I use the fitBounds method for an area around the pole. Leaflet only accept bounds in LatLngs and not in projected coordinates. This still seems to be the case with this refactoring. Any plans to support projected coordinates for the fitBounds method, L.Rectangle etc.? |
|
This looks really nice and really helpful for Proj4Leaflet. Well done! |
|
Thanks for the feedback guys! @turban yeah, it's not currently possible to pass projected coordinates to |
|
Merged, yay! 🔨 |
|
I have few comments about
Have you considered possibility not to create DOM elements for some tiles (for example, allow |
|
|
Here is a test case for "2": http://jsfiddle.net/dh76y/ |
|
@turban did you get your "Lambert Azimuthal Equal Area Projection" map working after all latest changes? starting same today, just curious about known issues… |
|
@dobrych Using a polar projection with Leaflet is still difficult I think, because lack of support for projected coordinates. You're better off with D3.js or OpenLayers. |
|
@turban thanks for confirmation, you saved me some time :-) already started D3 version in parallel, will see if tile layer of d3 will work properly with polar projection |
|
I'm interested in what issues you're seeing, feel free to report and problems to Proj4Leaflet (which I would assume you would want to use in this case). There is a branch to be used together with the new projection/CRS changes in Leaflet master: https://github.com/kartena/Proj4Leaflet/tree/leaflet-proj-refactor |
|
@perliedman Proj4Leaflet works good with cylindrical (pseudo)cylindrical projections, I'm using it for various maps in UTM and Mollweide projections. The problem araise with a projection where you need to operate in projected coordinates, not only geographical (latitude and longitude). If you have a polar projection like the one shown one the screenshot above, and want to use fitBounds to set the map view with the North Pole in the middle - it's not possible with the current fitBounds method. There are also issues with L.rectangle and L.Circle. Would be nice if you add a fix for this in Proj4Leaflet :-) |
|
Sorry that I didn't read your previous comment. If I understand correctly, the problem is not showing the tiles and not that there are actual bugs related to polar projections, but rather that the API isn't very useful in this use case, since for example bounds in the form of latitudes and longitudes does not make much sense, right? I can definitely see that it would be a problem. I'll try to think of if there's anything we can do in Proj4Leaflet to help this! |
|
True, the problem is not showing the tiles, but setting the view and drawing vectors on top when latitude and longitudes don't make sense. |
|
What is the intended replacement for |
|
@atombender check out the |
|
@mourner That's perfect, thank you. |

This is a major refactoring of TileLayer code and everything that is related to projections.
The TileLayer part that splits it into GridLayer and TileLayer will make the code much cleaner and allow to build other tile-based implementations easier.
The long-standing projections refactoring will remove all corresponding ugly hacks across the code, consolidate everything projections-related into one place, make creating flat maps much easier, and also remove the need for ugly hacks in Proj4Leaflet plugin for different obscure projections.
GridLayer + TileLayer
TileLayerintoGridLayer(with all the grid / tile positioning logic) and its childTileLayer(with logic for loading image tiles from tile servers)TileLayer.Anim.js, split animation logic betweenGridLayerandTileLayerGrid/TileLayerimplementations, make everything work depending on CRSTileLayer.Canvasin favor of a much more flexible and powerfulGridLayerGridLayerto allow negative coordinate spaceGridLayerwith some testsCRS & Projections
Projectionboundsproperty which determines projected coordinates boundsCRSproperties:wrapLng,wrapLat(determining whether the world wraps and how) andinfinite(if true, the layer will not be bounded, with negative tiles etc.)CRSgetProjectedBoundsthat returns projected world bounds for zoom and correspondingMapgetPixelWorldBounds, derived fromProjectionbounds, used for wrapping/bounding tilesEPSG:4326to have 2x1 tiles at zoom 0, EPSG 4326 Support Broken for TileLayers #1207Projection.SphericalMercatorto project to meter unitsCRSunprojectLatLngwrapand addCRSandMapwrapLatLngthat depends on CRS, fix tiles' bounds are not wrapped before being checked against layer's bounds #1618 againMapDragworldCopyJumphardcoded logic to work for other projectionsCRSwith more testsMisc. changes
L.bindto prepend real arguments to bound ones, and use native bind where available (was needed for a part of the code)Before merge
Major Refactoring for 1.0 #2210 Refactor TileLayer #1180 Projections refactoring #2239