{ "metadata": { "name": "", "signature": "sha256:dc08dcf599a6125d21802a4b1c8fe771a27c265b89aee5fe9fff72c4074e21db" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "code", "collapsed": false, "input": [ "from IPython.display import HTML\n", "import folium" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 1 }, { "cell_type": "code", "collapsed": false, "input": [ "def inline_map(map):\n", " \"\"\"\n", " Embeds the HTML source of the map directly into the IPython notebook.\n", " \n", " This method will not work if the map depends on any files (json data). Also this uses\n", " the HTML5 srcdoc attribute, which may not be supported in all browsers.\n", " \"\"\"\n", " map._build_map()\n", " return HTML(''.format(srcdoc=map.HTML.replace('\"', '"')))\n", "\n", "def embed_map(map, path=\"map.html\"):\n", " \"\"\"\n", " Embeds a linked iframe to the map into the IPython notebook.\n", " \n", " Note: this method will not capture the source of the map into the notebook.\n", " This method should work for all maps (as long as they use relative urls).\n", " \"\"\"\n", " map.create_map(path=path)\n", " return HTML(''.format(path=path))" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 2 }, { "cell_type": "code", "collapsed": false, "input": [ "map = folium.Map(width=800,height=600,location=[44, -73], zoom_start=3)\n", "\n", "map.add_wms_layer(wms_name=\"Temperature\",\n", " wms_url=\"http://gis.srh.noaa.gov/arcgis/services/NDFDTemps/MapServer/WMSServer\",\n", " wms_format=\"image/png\",\n", " wms_layers= 16\n", " )\n", "\n", "map.add_tile_layer(tile_name='hfradar 1km',\n", " tile_url='http://hfradar.ndbc.noaa.gov/tilesavg.php?s=10&e=100&x={x}&y={y}&z={z}&t=2014-8-18 14:00:00&rez=1')\n", "map.add_tile_layer(tile_name='hfradar 2km',\n", " tile_url='http://hfradar.ndbc.noaa.gov/tilesavg.php?s=10&e=100&x={x}&y={y}&z={z}&t=2014-8-18 14:00:00&rez=2')\n", "map.add_tile_layer(tile_name='hfradar 6km',\n", " tile_url='http://hfradar.ndbc.noaa.gov/tilesavg.php?s=10&e=100&x={x}&y={y}&z={z}&t=2014-8-18 14:00:00&rez=6')\n", "\n", "map.add_layers_to_map()" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 3 }, { "cell_type": "code", "collapsed": false, "input": [ "inline_map(map) " ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "" ], "metadata": {}, "output_type": "pyout", "prompt_number": 4, "text": [ "" ] } ], "prompt_number": 4 }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 4 } ], "metadata": {} } ] }