ipyleaflet
ipyleaflet copied to clipboard
Custom projections
I'm hoping for some help using a custom projection with ipyleaflet.
My ultimate goal is to have a slippy map viewer for non-geospatial images (think microscopy).
I'm struggling to get the Map crs correct so that the tile layer aligns with the coordinates I expect.
Can someone help me refine this example?
from ipyleaflet import Map, basemaps, projections, Rectangle, TileLayer
size_x, size_y = 500, 500
crs = dict(
name='PixelSpace',
custom=True,
resolutions=[256 * 2 ** (-l) for l in range(20)],
proj4def='+proj=longlat +axis=esu',
bounds=[[0, 0], [size_y, size_x]],
origin=[0, 0],
)
# a debug tile layer that returns a PNG with "x/y/z" in a box
debug = TileLayer(url='https://tileserver.banesullivan.com/api/tiles/debug/{z}/{x}/{y}.png')
rectangle = Rectangle(bounds=[[0,0], [size_y, size_x]])
m = Map(basemap=debug, zoom=0, crs=crs, center=[size_y/2, size_x/2])
m.add_layer(rectangle)
m
I expect the tile layer to only load within the bounds of the rectangle.