Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Work in progress
Fixes #30.
This PR attempts to make xarray_leaflet work on Windows. There are a few fairly simple changes around paths etc that are needed to make it work on Windows, so I've done those. There are also some bigger changes that I've detailed below, which we may need to discuss.
At the moment I haven't tested this version on Linux or OS X, so I don't know which my Windows changes may have broken it on other platforms - I imagine there will need to be some alterations to make this work on all platforms.
So, on to the issues:
_start()
wasn't being called, as themap_ready
traitlet was never being set to True. This turned out to be some weird async issue where the following line inasync_wait_for_bounds
was hanging and never returning:Commenting this out, and passing a
get_base_url
function in the original call toleaflet.plot
(for exampleimg.leaflet.plot(m, get_base_url=lambda x: "http://localhost:8888")
) seems to work. I see that the code is going to quite a lot of effort to try and get the base URL, by using bits of the Jupyter widgets code. The authors of stackstac - which has ashow
function which provides similar functionality to xarray_leaflet, but only for dask-backed xarrays - also came across this problem, and solved it with a fairly simple regex as follows:(taken from here)
How would you feel about removing the URL widget based code, and switching to just using this as the default value for
get_base_url
?_start()
method was called, and sometimes theLocalTileLayer
would be present in the list of layers, but wouldn't actually display on the map. I also had some confusion about thepath
andurl
parameters ofLocalTileLayer
- as sometimes only one was set, and sometimes both were set - even though the code doesn't seem to set theurl
parameter at all.Therefore, I tried switching to use the
TileLayer
class instead - as we're actually using a URL anyway, so we don't need any of the 'local' bit of LocalTileLayer. This seemed to fix the problem and it might be a better approach, as it probably takes away the complexity of the 'local' bit.So in summary: this branch works on Windows, but will need some more work to make it support all platforms. I've done a change from LocalTileLayer to TileLayer, and am proposing a change from the URL widget-based base_url calculation to a regex-based calculation.
What do you think? Is it worth me continuing with this PR?