banesullivan / localtileserver

🌐 dynamic tile server for visualizing rasters in Jupyter with ipyleaflet or folium
https://localtileserver.banesullivan.com
MIT License
304 stars 29 forks source link

Rasters do not render when using solara #215

Closed jmarokhovsky closed 4 months ago

jmarokhovsky commented 4 months ago

Description

I was attempting to render rasters in solara via leafmap (and more recently in ipyleaflet like in your example) and, while the map centers where the raster should be, the raster does not appear.

What I did

Below is the code I used to attempt to reproduce your example from the readme in solara:

# from localtileserver import TileClient, get_leaflet_tile_layer, examples
import localtileserver
from ipyleaflet import Map
from reacton import component as component
import solara

class LMap(Map):
    def __init__(self, **kwargs):
        # client = examples.get_san_francisco()  # use example data
        client = localtileserver.TileClient("/aqua_app/data/foo.tif")
        super().__init__(center=client.center(), zoom=client.default_zoom, **kwargs)

        # Create ipyleaflet TileLayer from that server
        t = localtileserver.get_leaflet_tile_layer(client)
        # Create ipyleaflet map, add tile layer, and display
        self.add(t)

@component
def Page():
    with solara.Column(style={"min_width": "500px"}):
        LMap.element()

Which results in this being displayed: Screenshot 2024-07-02 at 17 10 55

Report():

--------------------------------------------------------------------------------
  Date: Tue Jul 02 20:37:41 2024 UTC

                OS : Linux (Ubuntu 22.04)
            CPU(s) : 11
           Machine : aarch64
      Architecture : 64bit
               RAM : 7.7 GiB
       Environment : IPython

  Python 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]

   localtileserver : 0.10.3
             click : 8.1.7
             flask : 3.0.3
     flask_caching : 2.3.0
        flask_cors : 4.0.1
       flask_restx : 1.3.0
             numpy : 1.26.4
          rasterio : 1.3.10
         rio_cogeo : 5.3.2
         rio_tiler : 6.6.1
     server_thread : 0.2.0
          werkzeug : 3.0.3
            folium : 0.17.0
        ipyleaflet : 0.19.1
        matplotlib : 3.9.0
           shapely : 2.0.4
         traitlets : 5.14.3
--------------------------------------------------------------------------------
banesullivan commented 4 months ago

This is almost certainly due to not setting the proxy port mechanism rather than anything specific to usage with Solara. See:

Hope this helps

jmarokhovsky commented 4 months ago

Good to know, I'll let you know if I can manage to get it working on solara, but it won't be my main focus so for now this can probably be closed. I'll reopen/open a new bug if I do manage to find something different than the above issues. Thanks for all the help!