diff --git a/docs/notebooks/83_vector_viz.ipynb b/docs/notebooks/83_vector_viz.ipynb index 81898e5f74..0f52dec394 100644 --- a/docs/notebooks/83_vector_viz.ipynb +++ b/docs/notebooks/83_vector_viz.ipynb @@ -35,7 +35,8 @@ "outputs": [], "source": [ "import leafmap.deckgl as leafmap\n", - "import geopandas as gpd" + "import geopandas as gpd\n", + "import ipywidgets as widgets" ] }, { @@ -128,7 +129,54 @@ }, "outputs": [], "source": [ - "m.layers[-1].get_fill_color = [0, 0, 255, 255]" + "layer = m.layers[-1]\n", + "layer.get_fill_color = [0, 0, 255, 255]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Interactive widgets." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "color = widgets.ColorPicker(value='red', description='Color')\n", + "width = widgets.IntSlider(min=1, max=100, value=10, description='Radius')\n", + "hbox = widgets.HBox([color, width])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "widgets.dlink((color, 'value'), (layer, 'get_fill_color'))\n", + "widgets.dlink((width, 'value'), (layer, 'get_radius'))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "hbox" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "m" ] } ], @@ -148,7 +196,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.5" + "version": "3.11.6" } }, "nbformat": 4, diff --git a/examples/notebooks/83_vector_viz.ipynb b/examples/notebooks/83_vector_viz.ipynb index 81898e5f74..0f52dec394 100644 --- a/examples/notebooks/83_vector_viz.ipynb +++ b/examples/notebooks/83_vector_viz.ipynb @@ -35,7 +35,8 @@ "outputs": [], "source": [ "import leafmap.deckgl as leafmap\n", - "import geopandas as gpd" + "import geopandas as gpd\n", + "import ipywidgets as widgets" ] }, { @@ -128,7 +129,54 @@ }, "outputs": [], "source": [ - "m.layers[-1].get_fill_color = [0, 0, 255, 255]" + "layer = m.layers[-1]\n", + "layer.get_fill_color = [0, 0, 255, 255]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Interactive widgets." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "color = widgets.ColorPicker(value='red', description='Color')\n", + "width = widgets.IntSlider(min=1, max=100, value=10, description='Radius')\n", + "hbox = widgets.HBox([color, width])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "widgets.dlink((color, 'value'), (layer, 'get_fill_color'))\n", + "widgets.dlink((width, 'value'), (layer, 'get_radius'))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "hbox" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "m" ] } ], @@ -148,7 +196,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.5" + "version": "3.11.6" } }, "nbformat": 4, diff --git a/leafmap/deckgl.py b/leafmap/deckgl.py index 86fed2dc35..c6e18f0a5a 100644 --- a/leafmap/deckgl.py +++ b/leafmap/deckgl.py @@ -6,7 +6,7 @@ import geopandas as gpd except ImportError: - raise ( + raise Exception( "lonboard needs to be installed to use this module. Use 'pip install lonboard' to install the package." )