Constrain bounds of TileLayer
See original GitHub issueWould it be possible to add a property to the TileLayer
that will constrain its bounds?
The lack of constraint poses a problem when accessing a tile server I have that serves individual rasters (small coverage, not global). The TileLayer
continues to make requests from my tile server anytime I zoom out/view outside the data bounds, overloading my tile server which is just returning a bunch of transparent PNGs.
The logic I’m looking for:
t = TileLayer(
url="https://mytileserver.com/tiles/{z}/{x}/{y}.png?projection=EPSG:3857",
# Do not request tile outside of these bounds (bottom, top, left, right)
bounds=[37.40679, 38.080379, -122.759396, -122.065103],
)
From what I can tell, the leaflet JS tileLayer does have an option for bounds
that is inherited from gridLayer but this does not seem to be wrapped in ipyleaflet
. Ref https://leafletjs.com/reference.html#tilelayer
Example data:
Additional context:
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
Constrained Extent - OpenLayers
This map has a view that is constrained in an extent. This is done using the extent view option. Please note that specifying...
Read more >Manage hosted tile layers—ArcGIS Online Help | Documentation
Archive current content in a new layer. In this example scenario, you have a vector tile layer that stores service area boundaries. This...
Read more >Leaflet - Prevent loading tiles outside of MaxBounds
To tell Leaflet that your Tile Layers does not have any tile to serve outside predefined bounds, simply use the bounds option.
Read more >LeafletJS: Load Tile Layer based on bounding box
L.tileLayer does accept bounds parameter. I found it by digging into the code, but it is currently missing from the documentation.
Read more >View bounds - React Leaflet
Click a rectangle to fit the map to its bounds. ... <MapContainer bounds={outerBounds} scrollWheelZoom={false}>. <TileLayer.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Aha! That’s awesome! I can confirm that
((south, west), (north, east))
works!There’s a nifty “debug” tile server in
localtileserver
which is live here:https://tileserver.banesullivan.com/tiles/debug/{z}/{x}/{y}.png?sleep=0
Not quite, the bounds must be in the form:
I’ll open a PR.