{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from ipyleaflet import Map, Marker, Circle, CircleMarker, LayerGroup, basemaps" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "m = Map(center=(52, 10), zoom=8, basemap=basemaps.Hydda.Full)\n", "m" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Create a few layers\n", "marker = Marker(location=(52, 10))\n", "circle = Circle(location=(52, 12), radius=50000)\n", "circle_marker = CircleMarker(location=(52, 9), radius=10, color=\"red\", fill_color=\"red\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Create a group of layers and add it to the Map\n", "group = LayerGroup(layers=(marker,))\n", "m.add_layer(group)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Add new layers to the group\n", "group.add_layer(circle)\n", "group.add_layer(circle_marker)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Remove one layer from the group\n", "group.remove_layer(marker)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Remove layers from the group\n", "group.clear_layers()" ] } ], "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.4" } }, "nbformat": 4, "nbformat_minor": 2 }