{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0.3.0.dev\n" ] } ], "source": [ "import os\n", "import folium\n", "\n", "print(folium.__version__)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Examples of plugins usage in folium" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In this notebook we show a few illustrations of folium's plugin extensions.\n", "\n", "This is a development notebook" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Adds a button to enable/disable zoom scrolling." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## ScrollZoomToggler" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from folium import plugins\n", "\n", "\n", "m = folium.Map([45, 3], zoom_start=4)\n", "\n", "plugins.ScrollZoomToggler().add_to(m)\n", "\n", "m.save(os.path.join('results', 'Plugins_0.html'))\n", "\n", "m" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## MarkerCluster" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Adds a MarkerCluster layer on the map." ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import numpy as np\n", "\n", "\n", "N = 100\n", "\n", "data = np.array(\n", " [\n", " np.random.uniform(low=35, high=60, size=N), # Random latitudes in Europe.\n", " np.random.uniform(low=-12, high=30, size=N), # Random longitudes in Europe.\n", " range(N), # Popups texts are simple numbers.\n", " ]\n", ").T\n", "\n", "m = folium.Map([45, 3], zoom_start=4)\n", "\n", "plugins.MarkerCluster(data).add_to(m)\n", "\n", "m.save(os.path.join('results', 'Plugins_1.html'))\n", "\n", "m" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Terminator" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "m = folium.Map([45, 3], zoom_start=1)\n", "\n", "plugins.Terminator().add_to(m)\n", "\n", "m.save(os.path.join('results', 'Plugins_2.html'))\n", "\n", "m" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Leaflet.boatmarker" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "m = folium.Map([30, 0], zoom_start=3)\n", "\n", "plugins.BoatMarker(\n", " location=(34, -43),\n", " heading=45,\n", " wind_heading=150,\n", " wind_speed=45,\n", " color='#8f8'\n", ").add_to(m)\n", "\n", "plugins.BoatMarker(\n", " location=(46, -30),\n", " heading=-20,\n", " wind_heading=46,\n", " wind_speed=25,\n", " color='#88f'\n", ").add_to(m)\n", "\n", "\n", "m.save(os.path.join('results', 'Plugins_3.html'))\n", "\n", "m" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Fullscreen" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "m = folium.Map(location=[41.9, -97.3], zoom_start=4)\n", "\n", "plugins.Fullscreen(\n", " position='topright',\n", " title='Expand me',\n", " titleCancel='Exit me',\n", " forceSeparateButton=True).add_to(m)\n", "\n", "\n", "m.save(os.path.join('results', 'Plugins_4.html'))\n", "\n", "m # Click on the top right button." ] } ], "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.5.2" } }, "nbformat": 4, "nbformat_minor": 0 }