diff --git a/examples/introduction.ipynb b/examples/introduction.ipynb index aa456d9..0c0a0c6 100644 --- a/examples/introduction.ipynb +++ b/examples/introduction.ipynb @@ -9,7 +9,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -18,13 +18,13 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "47a42e9446f44146a853ebba1de8b8c8", + "model_id": "2f268e1adb234ab19da2eecccc7167c0", "version_major": 2, "version_minor": 0 }, @@ -32,7 +32,7 @@ "Map(center=[5.314329221346643, 16.3625002926901], zoom=9.0)" ] }, - "execution_count": 26, + "execution_count": 2, "metadata": {}, "output_type": "execute_result" } @@ -44,7 +44,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -54,7 +54,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -64,26 +64,27 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ - "geo_tiff_layer = GeoTIFFTileLayer(\n", - " sources=[\n", - " {'url': 'https://sentinel-cogs.s3.us-west-2.amazonaws.com/sentinel-s2-l2a-cogs/36/Q/WD/2020/7/S2A_36QWD_20200701_0_L2A/TCI.tif'}\n", - " ]\n", - ")\n", + "geo_tiff_layer = GeoTIFFTileLayer(url= 'https://sentinel-cogs.s3.us-west-2.amazonaws.com/sentinel-s2-l2a-cogs/36/Q/WD/2020/7/S2A_36QWD_20200701_0_L2A/TCI.tif')\n", "m.add_layer(geo_tiff_layer)" ] }, { - "cell_type": "code", - "execution_count": 15, + "cell_type": "markdown", "metadata": {}, - "outputs": [], "source": [ "m.remove_layer(geo_tiff_layer)" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { diff --git a/ipyopenlayers/Map.py b/ipyopenlayers/Map.py index 06e5ad5..aaf5dcc 100644 --- a/ipyopenlayers/Map.py +++ b/ipyopenlayers/Map.py @@ -42,7 +42,7 @@ class GeoJSON(Layer): class GeoTIFFTileLayer(Layer): _model_name = Unicode('GeoTIFFTileLayerModel').tag(sync=True) _view_name = Unicode('GeoTIFFTileLayerView').tag(sync=True) - sources = List(Dict).tag(sync=True) + url = Unicode('').tag(sync=True) class HeatmapLayer(Layer): _view_name = Unicode('HeatmapLayerView').tag(sync=True) @@ -52,8 +52,6 @@ class HeatmapLayer(Layer): radius = Int(8).tag(sync=True) - - class BaseOverlay(DOMWidget): _model_module = Unicode(module_name).tag(sync=True) diff --git a/src/geotifflayer.ts b/src/geotifflayer.ts index 13aa7c4..efba31d 100644 --- a/src/geotifflayer.ts +++ b/src/geotifflayer.ts @@ -16,7 +16,7 @@ export class GeoTIFFTileLayerModel extends LayerModel { _view_name: GeoTIFFTileLayerModel.view_name, _view_module: GeoTIFFTileLayerModel.view_module, _view_module_version: GeoTIFFTileLayerModel.view_module_version, - source: [], + url: '', }; } @@ -37,33 +37,30 @@ export class GeoTIFFTileLayerView extends LayerView { render() { super.render(); this.sourcesChanged(); - this.model.on('change:sources', this.sourcesChanged, this); + this.model.on('change:url', this.sourcesChanged, this); } create_obj() { - const sources = this.model.get('sources').map((source: any) => ({ - url: source.url, - })); + const url = this.model.get('url'); - this.obj = this.tileLayer = new WebGLTileLayer({ - source: new GeoTIFF({ - sources: sources, - }), - }); + if (url) { + this.obj = new WebGLTileLayer({ + source: new GeoTIFF({ + sources: [{ url: url }], + }), + }); + } } - sourcesChanged() { - const newSources = this.model.get('sources').map((source: any) => ({ - url: source.url, - })); + const newUrl = this.model.get('url'); - if (newSources) { + if (newUrl) { const newSource = new GeoTIFF({ - sources: newSources, + sources: [{ url: newUrl }], }); - this.tileLayer.setSource(newSource); + this.obj.setSource(newSource); } } - tileLayer: WebGLTileLayer; + obj: WebGLTileLayer; } diff --git a/ui-tests/tests/ipyopenlayers.test.ts-snapshots/light-map-update-ipynb-cell-0-linux.png b/ui-tests/tests/ipyopenlayers.test.ts-snapshots/light-map-update-ipynb-cell-0-linux.png index bffbc64..d9be678 100644 Binary files a/ui-tests/tests/ipyopenlayers.test.ts-snapshots/light-map-update-ipynb-cell-0-linux.png and b/ui-tests/tests/ipyopenlayers.test.ts-snapshots/light-map-update-ipynb-cell-0-linux.png differ diff --git a/ui-tests/tests/ipyopenlayers.test.ts-snapshots/light-map-update-ipynb-cell-1-linux.png b/ui-tests/tests/ipyopenlayers.test.ts-snapshots/light-map-update-ipynb-cell-1-linux.png index bffbc64..63be347 100644 Binary files a/ui-tests/tests/ipyopenlayers.test.ts-snapshots/light-map-update-ipynb-cell-1-linux.png and b/ui-tests/tests/ipyopenlayers.test.ts-snapshots/light-map-update-ipynb-cell-1-linux.png differ diff --git a/ui-tests/tests/notebooks/map_update.ipynb b/ui-tests/tests/notebooks/map_update.ipynb index a1e71d6..f2be4bd 100644 --- a/ui-tests/tests/notebooks/map_update.ipynb +++ b/ui-tests/tests/notebooks/map_update.ipynb @@ -12,8 +12,7 @@ "outputs": [], "source": [ "from ipyopenlayers import (\n", - " Map, TileLayer, ImageOverlay, VideoOverlay, PopupOverlay,\n", - " ZoomSlider, FullScreen, ScaleLine, MousePosition\n", + " Map, RasterTileLayer\n", ")\n", "\n", "m = Map(center=[0.0, 0.0], zoom=2)\n", @@ -31,7 +30,7 @@ }, "outputs": [], "source": [ - "layer = TileLayer()\n", + "layer = RasterTileLayer()\n", "m.add_layer(layer)" ] }