{ "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": "code", "execution_count": 2, "metadata": { "collapsed": true }, "outputs": [], "source": [ "lon, lat = -38.625, -12.875\n", "\n", "zoom_start = 8" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "m = folium.Map(location=[lat, lon], tiles=\"OpenStreetMap\", zoom_start=zoom_start)\n", "\n", "m.save(os.path.join('results', 'TilesExample_0.html'))\n", "\n", "m" ] }, { "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(location=[lat, lon], tiles=\"Mapbox Bright\", zoom_start=zoom_start)\n", "\n", "m.save(os.path.join('results', 'TilesExample_1.html'))\n", "\n", "m" ] }, { "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(location=[lat, lon], tiles=\"Mapbox Control Room\", zoom_start=zoom_start)\n", "\n", "m.save(os.path.join('results', 'TilesExample_2.html'))\n", "\n", "m" ] }, { "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=[lat, lon], tiles=\"Stamen Terrain\", zoom_start=zoom_start)\n", "\n", "m.save(os.path.join('results', 'TilesExample_3.html'))\n", "\n", "m" ] }, { "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(location=[lat, lon], tiles=\"Stamen Toner\", zoom_start=zoom_start)\n", "\n", "m.save(os.path.join('results', 'TilesExample_4.html'))\n", "\n", "m" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "m = folium.Map(location=[lat, lon], tiles=\"Stamen Watercolor\", zoom_start=zoom_start)\n", "\n", "m.save(os.path.join('results', 'TilesExample_5.html'))\n", "\n", "m" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "m = folium.Map(location=[lat, lon], tiles=\"Cartodb Positron\", zoom_start=zoom_start)\n", "\n", "m.save(os.path.join('results', 'TilesExample_6.html'))\n", "\n", "m" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "m = folium.Map(location=[lat, lon], tiles=\"Cartodb dark_matter\", zoom_start=zoom_start)\n", "\n", "m.save(os.path.join('results', 'TilesExample_7.html'))\n", "\n", "m" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Custom tiles" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "attr = ('© OpenStreetMap '\n", " 'contributors, © CartoDB')\n", "tiles = 'http://{s}.basemaps.cartocdn.com/light_nolabels/{z}/{x}/{y}.png'\n", "\n", "m = folium.Map(location=[lat, lon], tiles=tiles, attr=attr, zoom_start=zoom_start)\n", "\n", "m.save(os.path.join('results', 'TilesExample_8.html'))\n", "\n", "m\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### There are plenty tile sources to choose from:" ] }, { "cell_type": "code", "execution_count": 12, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "\n", " \n", " " ], "text/plain": [ "" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from IPython.display import IFrame\n", "\n", "IFrame('http://leaflet-extras.github.io/leaflet-providers/preview/', width=900, height=750)" ] } ], "metadata": { "anaconda-cloud": {}, "kernelspec": { "display_name": "Python [default]", "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.4.5" } }, "nbformat": 4, "nbformat_minor": 1 }