{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0.5.0+27.g2d457b0.dirty\n" ] } ], "source": [ "import os\n", "import folium\n", "\n", "print(folium.__version__)" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import json\n", "\n", "us_states = os.path.join('data', 'us-states.json')\n", "\n", "with open(us_states) as f:\n", " states = json.load(f)\n", "\n", "kw = {'location': [48, -102], 'zoom_start': 3}" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from folium import GeoJson\n", "\n", "m = folium.Map(tiles=None, **kw)\n", "\n", "GeoJson(states).add_to(m)\n", "\n", "m.save(os.path.join('results', 'GeoJSONWithoutTitles_0.html'))\n", "\n", "m" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import branca\n", "\n", "# Create a white image of 4 pixels, and embed it in a url.\n", "white_tile = branca.utilities.image_to_url([[1, 1], [1, 1]])\n", "\n", "# Create a map using this url for each tile.\n", "m = folium.Map(tiles=white_tile, attr='white tile', **kw)\n", "\n", "GeoJson(states).add_to(m)\n", "\n", "m.save(os.path.join('results', 'GeoJSONWithoutTitles_1.html'))\n", "\n", "m" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "images = [[(-1)**((i+j)//30) for i in range(300)] for j in range(300)]\n", "\n", "tiles = branca.utilities.image_to_url(images)\n", "\n", "m = folium.Map(tiles=tiles, attr='Just because we can', **kw)\n", "\n", "GeoJson(states).add_to(m)\n", "\n", "m.save(os.path.join('results', 'GeoJSONWithoutTitles_2.html'))\n", "\n", "m" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "images = [[(-1)**((i//30+j//30)) for i in range(300)] for j in range(300)]\n", "\n", "tiles = branca.utilities.image_to_url(images)\n", "\n", "m = folium.Map(tiles=tiles, attr='Just because we can', **kw)\n", "\n", "GeoJson(states).add_to(m)\n", "\n", "m.save(os.path.join('results', 'GeoJSONWithoutTitles_3.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.6.2" } }, "nbformat": 4, "nbformat_minor": 1 }