{
"metadata": {
"name": "",
"signature": "sha256:6dfa186feeffb3d029e244faef5cd7c75b438c815731793cb01200120c064258"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "code",
"collapsed": false,
"input": [
"from IPython.display import HTML\n",
"import folium\n",
"\n",
"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=\"m213map.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": 6
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"map = folium.Map(width=500,height=500,location=[44, -73], zoom_start=4)\n",
"\n",
"map.simple_marker([40.67, -73.94], popup='Add popup text here.',marker_color='green',marker_icon='ok-sign',clustered_marker=True)\n",
"map.simple_marker([44.67, -73.94], popup='Add popup text here.',marker_color='red',marker_icon='remove-sign',clustered_marker=True)\n",
"map.simple_marker([44.67, -71.94], popup='Add popup text here.',clustered_marker=True)\n",
"\n",
"map.circle_marker([44, -71], popup='', fill_color='#ff0000', radius=5000, line_color='#ff0000')\n",
"\n",
"points1 = [40,-71]\n",
"points2 = [42,-73]\n",
"map.line([points1, points2])\n",
"\n",
"inline_map(map)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"html": [
""
],
"metadata": {},
"output_type": "pyout",
"prompt_number": 7,
"text": [
""
]
}
],
"prompt_number": 7
},
{
"cell_type": "code",
"collapsed": false,
"input": [],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 7
},
{
"cell_type": "code",
"collapsed": false,
"input": [],
"language": "python",
"metadata": {},
"outputs": []
}
],
"metadata": {}
}
]
}