{
 "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('<iframe srcdoc=\"{srcdoc}\" style=\"width: 100%; height: 510px; border: none\"></iframe>'.format(srcdoc=map.HTML.replace('\"', '&quot;')))\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('<iframe src=\"files/{path}\" style=\"width: 100%; height: 510px; border: none\"></iframe>'.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 <b>popup</b> text here.',marker_color='green',marker_icon='ok-sign',clustered_marker=True)\n",
      "map.simple_marker([44.67, -73.94], popup='Add <b>popup</b> text here.',marker_color='red',marker_icon='remove-sign',clustered_marker=True)\n",
      "map.simple_marker([44.67, -71.94], popup='Add <b>popup</b> 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": [
        "<iframe srcdoc=\"<!DOCTYPE html>\n",
        "<head>\n",
        "   <meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=UTF-8&quot; />\n",
        "   <link rel=&quot;stylesheet&quot; href=&quot;http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.css&quot; />\n",
        "   <script src=&quot;http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.js&quot;></script>\n",
        "\n",
        "   <script src=&quot;https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js&quot;></script>\n",
        "\n",
        "   <link rel=&quot;stylesheet&quot; href=&quot;//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css&quot;>\n",
        "   <link rel=&quot;stylesheet&quot; href=&quot;//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css&quot;>\n",
        "   <script src=&quot;//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js&quot;></script>\n",
        "\n",
        "   <link rel=&quot;stylesheet&quot; href=&quot;//cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.0/leaflet.awesome-markers.css&quot;>\n",
        "   <script src=&quot;//cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.0/leaflet.awesome-markers.js&quot;></script>\n",
        "\n",
        "\n",
        "   <link rel=&quot;stylesheet&quot; href=&quot;//cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/0.4.0/MarkerCluster.Default.css&quot;>\n",
        "   <link rel=&quot;stylesheet&quot; href=&quot;//cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/0.4.0/MarkerCluster.css&quot;>\n",
        "   <script src=&quot;//cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/0.4.0/leaflet.markercluster-src.js&quot;></script>\n",
        "   <script src=&quot;//cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/0.4.0/leaflet.markercluster.js&quot;></script>\n",
        "\n",
        "   \n",
        "\n",
        "   \n",
        "   \n",
        "   \n",
        "   \n",
        "\n",
        "\n",
        "   <style>\n",
        "\n",
        "      #map {\n",
        "        position:absolute;\n",
        "        top:0;\n",
        "        bottom:0;\n",
        "        right:0;\n",
        "        left:0;\n",
        "      }\n",
        "\n",
        "   </style>\n",
        "</head>\n",
        "\n",
        "<body>\n",
        "\n",
        "   <div class=&quot;folium-map&quot; id=&quot;folium_9e79bd032eb94e15a717ee68977d0895&quot; style=&quot;width: 500px; height: 500px&quot;></div>\n",
        "\n",
        "   <script>\n",
        "\n",
        "      \n",
        "\n",
        "      var map = L.map('folium_9e79bd032eb94e15a717ee68977d0895').setView([44, -73], 4);\n",
        "\n",
        "      L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {\n",
        "          maxZoom: 18,\n",
        "          attribution: 'Map data (c) <a href=&quot;http://openstreetmap.org&quot;>OpenStreetMap</a> contributors'\n",
        "      }).addTo(map);\n",
        "\n",
        "      //cluster group\n",
        "      var clusteredmarkers = L.markerClusterGroup();\n",
        "      //section for adding clustered markers\n",
        "      \n",
        "      var marker_1_icon = L.AwesomeMarkers.icon({ icon: 'ok-sign',markerColor: 'green',prefix: 'glyphicon' });\n",
        "      var marker_1 = L.marker([40.67, \n",
        "\t\t\t\t\t\t\t-73.94],\n",
        "\t\t\t\t\t\t\t{'icon':marker_1_icon}\n",
        "\t\t\t\t\t\t\t);\n",
        "      marker_1.bindPopup(&quot;Add <b>popup</b> text here.&quot;);\n",
        "      clusteredmarkers.addLayer(marker_1)\n",
        "      \n",
        "      var marker_2_icon = L.AwesomeMarkers.icon({ icon: 'remove-sign',markerColor: 'red',prefix: 'glyphicon' });\n",
        "      var marker_2 = L.marker([44.67, \n",
        "\t\t\t\t\t\t\t-73.94],\n",
        "\t\t\t\t\t\t\t{'icon':marker_2_icon}\n",
        "\t\t\t\t\t\t\t);\n",
        "      marker_2.bindPopup(&quot;Add <b>popup</b> text here.&quot;);\n",
        "      clusteredmarkers.addLayer(marker_2)\n",
        "      \n",
        "      var marker_3_icon = L.AwesomeMarkers.icon({ icon: 'info-sign',markerColor: 'blue',prefix: 'glyphicon' });\n",
        "      var marker_3 = L.marker([44.67, \n",
        "\t\t\t\t\t\t\t-71.94],\n",
        "\t\t\t\t\t\t\t{'icon':marker_3_icon}\n",
        "\t\t\t\t\t\t\t);\n",
        "      marker_3.bindPopup(&quot;Add <b>popup</b> text here.&quot;);\n",
        "      clusteredmarkers.addLayer(marker_3)\n",
        "      \n",
        "      //add the clustered markers to the group anyway\n",
        "      map.addLayer(clusteredmarkers);\n",
        "\n",
        "      \n",
        "\n",
        "      \n",
        "      var circle_1 = L.circle([44, -71], 5000, {\n",
        "                            color: '#ff0000',\n",
        "                            fillColor: '#ff0000',\n",
        "                            fillOpacity: 0.6\n",
        "                            });\n",
        "      circle_1.bindPopup(&quot;&quot;);\n",
        "      map.addLayer(circle_1)\n",
        "      \n",
        "\n",
        "      \n",
        "      var latLngs = [ [40, -71],  [42, -73], ];\n",
        "var line_1 = L.polyline(latLngs,{\n",
        "\n",
        "\n",
        "\n",
        "});\n",
        "      map.addLayer(line_1);\n",
        "      \n",
        "\n",
        "      \n",
        "\n",
        "      \n",
        "\n",
        "   </script>\n",
        "\n",
        "</body>\" style=\"width: 100%; height: 510px; border: none\"></iframe>"
       ],
       "metadata": {},
       "output_type": "pyout",
       "prompt_number": 7,
       "text": [
        "<IPython.core.display.HTML at 0x10fa29a90>"
       ]
      }
     ],
     "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": {}
  }
 ]
}