{ "metadata": { "name": "", "signature": "sha256:8ed40078e27491a3b3604490f01c0843aa53b6fc6a4116736b5c6d52731fdeca" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "code", "collapsed": false, "input": [ "from pyspatial.vector import read_layer\n", "from pyspatial.visualize import get_latlngs, HTMLMap\n", "import cPickle as pickle\n", "import pandas as pd\n", "from pyspatial.utils import projection_from_epsg" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 14 }, { "cell_type": "code", "collapsed": false, "input": [ "vl, vldf = read_layer(\"../test/data/vector/cb_2014_us_state_20m.zip\", index=\"STUSPS\")" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 15 }, { "cell_type": "code", "collapsed": false, "input": [ "# Get a resonable center for the map\n", "centroid = vl[\"KS\"].Centroid()\n", "lng, lat, z = centroid.GetPoint()" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 16 }, { "cell_type": "code", "collapsed": false, "input": [ "# Initialize the map\n", "hmap = HTMLMap(lat, lng, data=vldf)\n", "popup_text = [\"California\", \"New York\"]\n", "hmap.add_markers(\"markers\", vl[[\"CA\", \"NY\"]], text=popup_text)\n", "\n", "# For styling refer to http://leafletjs.com/reference.html#path\n", "hmap.add_shapes(\"shapes\", vl[[\"CA\", \"NY\"]], text=popup_text, style={\"fillColor\": \"red\"})\n", "hmap.render_ipython()" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "" ], "metadata": {}, "output_type": "pyout", "prompt_number": 20, "text": [ "" ] } ], "prompt_number": 20 } ], "metadata": {} } ] }