{ "cells": [ { "cell_type": "code", "execution_count": 5, "metadata": { "scrolled": false }, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "cde00be438e24a568b06c1c3da7f0c7a", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Map(basemap={'url': 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', 'max_zoom': 19, 'attribution': 'Map …" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "a63e14dd82e94b0eb778ec569fd426fd", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Label(value='Not Loading')" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from ipyleaflet import *\n", "from ipywidgets import *\n", "\n", "m = Map(center=(52, 10), zoom=8)\n", "\n", "tl = TileLayer(url='https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png')\n", "m.add_layer(tl)\n", "\n", "label = Label(value='Not Loading')\n", "\n", "def on_load_change(change):\n", " loading = change['new']\n", " label.value = str('Loading...' if loading else 'Not Loading')\n", "\n", "tl.observe(on_load_change, 'loading')\n", "\n", "display(m)\n", "display(label)\n", "\n", "# move the map, zoom out or zoom in to see the Label change from 'Loading...' to 'Not Loading'" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.8" } }, "nbformat": 4, "nbformat_minor": 4 }