{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "`ipyleaflet.basemaps` is a `Bunch`, in other words, a dictionary-like object providing auto-completion. Select from this bunch to obtain a valid entry for the basemap attribute, which is used to define the base layer.\n", "\n", "![basemap-demo](basemap-demo.gif)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from ipyleaflet import *" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "m = Map(center=(43, 10), zoom=6, basemap=basemaps.Hydda.Full)\n", "m" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Adding a few tile layers\n", "tile1 = basemap_to_tiles(basemaps.Esri.WorldImagery)\n", "tile2 = basemap_to_tiles(basemaps.Esri.WorldStreetMap)\n", "\n", "m.add_layer(tile1)\n", "m.add_layer(tile2)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Adding an overlay layer\n", "import json\n", "\n", "with open('./europe_110.geo.json') as f:\n", " data = json.load(f)\n", "for feature in data['features']:\n", " feature['properties']['style'] = {\n", " 'color': 'grey',\n", " 'weight': 1,\n", " 'fillColor': 'grey',\n", " 'fillOpacity': 0.5\n", " }\n", "geo = GeoJSON(data=data, hover_style={'fillColor': 'red'}, name='Countries')\n", "m.add_layer(geo)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Adding the control\n", "m.add_control(LayersControl())" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "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.3" } }, "nbformat": 4, "nbformat_minor": 2 }