{ "cells": [ { "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": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# This is to import the repository's version of folium ; not the installed one.\n", "import sys, os\n", "sys.path.insert(0,'..')\n", "import folium\n", "from folium import plugins" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import numpy as np\n", "import json" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## ScrollZoomToggler" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Adds a button to enable/disable zoom scrolling." ] }, { "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=4)\n", "plugins.ScrollZoomToggler().add_to(m)\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": 5, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "N = 100\n", "data = np.array([\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 are simple numbers \n", " ]).T\n", "m = folium.Map([45.,3.], zoom_start=4)\n", "plugins.MarkerCluster(data).add_to(m)\n", "m" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Terminator" ] }, { "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([45.,3.], zoom_start=1)\n", "plugins.Terminator().add_to(m)\n", "plugins.ScrollZoomToggler().add_to(m)\n", "m" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Leaflet.boatmarker" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "m = folium.Map([30.,0.], zoom_start=3)\n", "plugins.BoatMarker((34,-43), heading=45, wind_heading=150, wind_speed=45, color=\"#8f8\").add_to(m)\n", "plugins.BoatMarker((46,-30), heading=-20, wind_heading=46, wind_speed=25, color=\"#88f\").add_to(m)\n", "m" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.11" } }, "nbformat": 4, "nbformat_minor": 0 }