{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from ipyleaflet import Map, GeoData, basemaps, LayersControl\n", "import geopandas\n", "import json\n", "\n", "countries = geopandas.read_file(geopandas.datasets.get_path(\"naturalearth_lowres\"))\n", "rivers = geopandas.read_file(\n", " \"https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/physical/ne_10m_rivers_lake_centerlines.zip\"\n", ")\n", "\n", "m = Map(center=(28.6019917, 70.9121356), zoom=3, basemap=basemaps.Esri.WorldTopoMap)\n", "\n", "geo_data = GeoData(\n", " geo_dataframe=countries,\n", " style={\n", " \"color\": \"black\",\n", " \"fillColor\": \"#366370\",\n", " \"opacity\": 0.05,\n", " \"weight\": 1.9,\n", " \"dashArray\": \"2\",\n", " \"fillOpacity\": 0.6,\n", " },\n", " hover_style={\"fillColor\": \"#b08a3e\", \"fillOpacity\": 0.9},\n", " name=\"Countries\",\n", ")\n", "\n", "\n", "m.add(geo_data)\n", "m" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from ipywidgets import Text, HTML\n", "from ipyleaflet import WidgetControl, GeoJSON\n", "\n", "\n", "html = HTML(\"\"\"Hover over a state\"\"\")\n", "html.layout.margin = \"0px 20px 20px 20px\"\n", "control = WidgetControl(widget=html, position=\"topright\")\n", "m.add(control)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "def update_html(feature, **kwargs):\n", " html.value = \"\"\"\n", "