{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "737a2a07-5247-42d5-b06a-ff6a3bf21306", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [], "source": [ "import folium" ] }, { "cell_type": "markdown", "id": "dc86d298-4a92-41e2-8e9a-bcb2dd36d80f", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "[LatLon](https://www.latlong.net/)" ] }, { "cell_type": "code", "execution_count": 12, "id": "dbed7e42-d95e-4b25-91b8-248cd95f22ea", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [ { "data": { "text/html": [ "
Make this Notebook Trusted to load map: File -> Trust Notebook
" ], "text/plain": [ "" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "m = folium.Map(\n", " location=(52.264150, 10.526420),\n", " tiles='OpenStreetMap',\n", " #iles='Stamen Toner',\n", " zoom_start=13,\n", " prefer_canvas=False\n", " )\n", "\n", "m" ] }, { "cell_type": "code", "execution_count": 13, "id": "2b08e2f2-cf81-439b-b47f-733e123d72d3", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [ { "data": { "text/html": [ "
Make this Notebook Trusted to load map: File -> Trust Notebook
" ], "text/plain": [ "" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "my_marker = folium.Marker(\n", " location=(52.25802230834961, 10.503097534179688)\n", " )\n", "\n", "my_marker.add_to(m)\n", "\n", "m" ] }, { "cell_type": "code", "execution_count": 14, "id": "71dbf9b1-2217-40d5-bfa1-c38b2bbc6362", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [ { "data": { "text/html": [ "
Make this Notebook Trusted to load map: File -> Trust Notebook
" ], "text/plain": [ "" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "castle_popup = \"Ritterbrunnen 1, 38100 Braunschweig\"\n", "castle_tooltip = \"More about the castle\"\n", "\n", "\n", "castle_marker = folium.Marker(\n", " location=(52.2643, 10.529),\n", " popup=castle_popup,\n", " tooltip=castle_tooltip\n", " )\n", "castle_marker.add_to(m)\n", "\n", "m" ] }, { "cell_type": "code", "execution_count": 15, "id": "60c6bc4b-c339-4cd5-806d-66c879807b6e", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [], "source": [ "hbk_popup_html = folium.Popup(\n", " '''\n", "

\n", " \"HBK\n", "

\n", "

Johannes-Selenka-Platz 1

\n", "

38118 Braunschweig

\n", "

Germany, DE

\n", "

Visit: hbk-bs.de

\n", " ''',\n", " show=False\n", " )\n", "\n", "hbk_tooltip = \"More about the university\"" ] }, { "cell_type": "code", "execution_count": 16, "id": "19123dd9-c88d-4713-ab84-4cc692e3f663", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [], "source": [ "hbk_icon = folium.Icon(\n", " color='black',\n", " icon_color='#deddda',\n", " prefix='glyphicon',\n", " icon='glyphicon-home',\n", " angle=0\n", " )" ] }, { "cell_type": "code", "execution_count": 17, "id": "7f496828-e49a-4253-98e3-aaa59d0cdc1c", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [ { "data": { "text/html": [ "
Make this Notebook Trusted to load map: File -> Trust Notebook
" ], "text/plain": [ "" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "hbk_marker = folium.Marker(\n", " location=(52.257770, 10.502490),\n", " popup=hbk_popup_html,\n", " tooltip=hbk_tooltip,\n", " icon=hbk_icon\n", " )\n", "\n", "hbk_marker.add_to(m)\n", "\n", "m" ] }, { "cell_type": "markdown", "id": "78002786-20fb-4b92-be9a-b92b678f50ff", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "

\n", " \"HBK\n", "

Johannes-Selenka-Platz 1

\n", "

38118 Braunschweig

\n", "

Germany, DE

\n", "

Visit: hbk-bs.de\n", "

" ] }, { "cell_type": "code", "execution_count": 18, "id": "0547528b-b97f-4e94-aab4-d1d069be020c", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [], "source": [ "def popup_factory(adr: str, zipc: str, country: str, pic: str):\n", " html = '''\n", "

\n", "

{}

\n", "

{}

\n", "

{}

\n", " '''.format(pic, adr, zipc, country)\n", " return folium.Popup(html)" ] }, { "cell_type": "code", "execution_count": 19, "id": "2ec42850-9c12-4fb4-8b94-024bca9ad9b1", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [], "source": [ "def icon_factory(is_public=True):\n", " icon = folium.Icon(\n", " color='black' if is_public else 'white',\n", " icon_color = 'white' if is_public else 'black',\n", " icon='glyphicon-home'\n", " )\n", " return icon" ] }, { "cell_type": "code", "execution_count": 20, "id": "b3d3d3c8-0039-4f80-9f08-5de61172b588", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [], "source": [ "def marker_factory(loc, popup, is_public=True):\n", " std_tooltip = 'Click for more information'\n", " std_icon = icon_factory(is_public)\n", " return folium.Marker(loc, popup=popup, icon=std_icon, tooltip=std_tooltip)" ] }, { "cell_type": "code", "execution_count": null, "id": "18701dc2-4409-486d-ad7d-7bde6fc3273e", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [], "source": [] } ], "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.12.7" } }, "nbformat": 4, "nbformat_minor": 5 }