{ "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": [ "# Demostrate PolylineTextPath plugin" ] }, { "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", "m = folium.Map([30, 0], zoom_start=3)\n", "\n", "wind_locations = [\n", " [59.35560, -31.992190],\n", " [55.178870, -42.89062],\n", " [47.754100, -43.94531],\n", " [38.272690, -37.96875],\n", " [27.059130, -41.13281],\n", " [16.299050, -36.56250],\n", " [8.4071700, -30.23437],\n", " [1.0546300, -22.50000],\n", " [-8.754790, -18.28125],\n", " [-21.61658, -20.03906],\n", " [-31.35364, -24.25781],\n", " [-39.90974, -30.93750],\n", " [-43.83453, -41.13281],\n", " [-47.75410, -49.92187],\n", " [-50.95843, -54.14062],\n", " [-55.97380, -56.60156]\n", "]\n", "\n", "wind_line = folium.PolyLine(\n", " wind_locations,\n", " weight=15,\n", " color='#8EE9FF'\n", ").add_to(m)\n", "\n", "attr = {'fill': '#007DEF', 'font-weight': 'bold', 'font-size': '24'}\n", "\n", "plugins.PolyLineTextPath(\n", " wind_line,\n", " \") \",\n", " repeat=True,\n", " offset=7,\n", " attributes=attr\n", ").add_to(m)\n", "\n", "danger_line = folium.PolyLine(\n", " [[-40.311, -31.952],\n", " [-12.086, -18.727]],\n", " weight=10,\n", " color='orange',\n", " opacity=0.8\n", ").add_to(m)\n", "\n", "attr = {'fill': 'red'}\n", "\n", "plugins.PolyLineTextPath(\n", " danger_line,\n", " \"\\u25BA\",\n", " repeat=True,\n", " offset=6,\n", " attributes=attr\n", ").add_to(m)\n", "\n", "plane_line = folium.PolyLine(\n", " [[-49.38237, -37.26562],\n", " [-1.75754, -14.41406],\n", " [51.61802, -23.20312]],\n", " weight=1,\n", " color='black'\n", ").add_to(m)\n", "\n", "attr = {'font-weight': 'bold', 'font-size': '24'}\n", "\n", "plugins.PolyLineTextPath(\n", " plane_line,\n", " \"\\u2708 \",\n", " repeat=True,\n", " offset=8,\n", " attributes=attr\n", ").add_to(m)\n", "\n", "\n", "line_to_new_delhi = folium.PolyLine(\n", " [[46.67959447, 3.33984375],\n", " [46.5588603, 29.53125],\n", " [42.29356419, 51.328125],\n", " [35.74651226, 68.5546875],\n", " [28.65203063, 76.81640625]]\n", ").add_to(m)\n", "\n", "\n", "line_to_hanoi = folium.PolyLine(\n", " [[28.76765911, 77.60742188],\n", " [27.83907609, 88.72558594],\n", " [25.68113734, 97.3828125],\n", " [21.24842224, 105.77636719]]\n", ").add_to(m)\n", "\n", "\n", "plugins.PolyLineTextPath(\n", " line_to_new_delhi,\n", " \"To New Delhi\",\n", " offset=-5\n", ").add_to(m)\n", "\n", "\n", "plugins.PolyLineTextPath(\n", " line_to_hanoi,\n", " \"To Hanoi\",\n", " offset=-5\n", ").add_to(m)\n", "\n", "m.save(os.path.join('results', 'Polyline_text_path.html'))\n", "\n", "m" ] } ], "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 }