{ "cells": [ { "cell_type": "code", "execution_count": null, "id": "24ede0d7-88e1-4955-9094-e10a9aebe5e7", "metadata": {}, "outputs": [], "source": [ "from ipyleaflet import Map, GeoData\n", "import geopandas\n", "import numpy as np\n", "import shapely" ] }, { "cell_type": "code", "execution_count": null, "id": "c667213f-cfed-4f0c-835a-a52a0f57ffe8", "metadata": {}, "outputs": [], "source": [ "# Generate 100k random points around the world.\n", "\n", "point_count = 100000\n", "\n", "random_locs = np.array(\n", " [np.random.uniform(-90, 90, point_count), np.random.uniform(-180, 180, point_count)]\n", ").transpose((1, 0))" ] }, { "cell_type": "code", "execution_count": null, "id": "b7a07e2f-8396-4424-8ec0-8bdad8a1e982", "metadata": {}, "outputs": [], "source": [ "m = Map(center=(48.1, 17.1), zoom=8, prefer_canvas=True)\n", "\n", "gdf = geopandas.GeoDataFrame(\n", " geometry=[shapely.geometry.Point(loc) for loc in random_locs], crs=\"EPSG:4326\"\n", ")\n", "\n", "geo_data = GeoData(\n", " geo_dataframe=gdf,\n", " hover_style={\"fillColor\": \"red\", \"fillOpacity\": 0.2},\n", " point_style={\"radius\": 5, \"fillOpacity\": 0.8, \"fillColor\": \"blue\", \"weight\": 3},\n", ")\n", "\n", "m.add(geo_data)\n", "\n", "m" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.10.5" } }, "nbformat": 4, "nbformat_minor": 5 }