GithubHelp home page GithubHelp logo

gmaps's Introduction

Travis build status Latest version released on PyPi Latest documentation

gmaps

gmaps is a plugin for including interactive Google maps in the IPython Notebook.

Let's plot a heatmap of taxi pickups in San Francisco:

In [1]: import gmaps
        import gmaps.datasets
        gmaps.configure(api_key="AI...") # Your Google API key

# load a Numpy array of (latitude, longitude) pairs
In [2]: data = gmaps.datasets.load_dataset('taxi_rides')

In [3]: m = gmaps.Map()
        m.add_layer(gmaps.Heatmap(data=data))
        m

docs/example.png

Or, for coffee fans, a map of all Starbucks in the UK:

In [1]: import gmaps
        import gmaps.datasets

        gmaps.configure(api_key="AI...") # Your Google API key

In [2]: locations = gmaps.datasets.load_dataset("starbucks_uk")

In [3]: m = gmaps.Map()
        starbucks_layer = gmaps.symbol_layer(
            locations, fill_color="green", stroke_color="green", scale=2)
        m.add_layer(starbucks_layer)
        m

docs/source/starbucks-symbols.png

Installation

Dependencies

The current version of gmaps is only tested with IPython 4.2 or later and ipywidgets 5.2.2 and traitlets 4.3.0 or later. To upgrade to the latest versions, use:

$ pip install -U jupyter

Make sure that you have enabled widgets extensions to Jupyter:

$ jupyter nbextension enable --py --sys-prefix widgetsnbextension

Installing gmaps

Install the Python component using:

$ pip install gmaps

Then tell Jupyter to load the extension with:

$ jupyter nbextension enable --py gmaps

Development version

You must have NPM to install the development version. You can install NPM with your package manager.

You must also install gmaps in a virtual environment (or, at least, you must be able to run pip without root access).

Clone the git repository by running:

$ git clone https://github.com/pbugnion/gmaps.git

Change to the project's root directory and run:

$ pip install -e .

This will create a directory called static/ in the gmaps/ directory. This directory contains Javascript sources. Every time you change the Javascript sources, you will need to recompile this directory by re-running this command (despite everying being installed in editable mode).

You can then enable the extension in Jupyter:

$ jupyter nbextension install --py --symlink --user gmaps
$ jupyter nbextension enable --py --user gmaps

Google API keys

To access Google maps, gmaps needs a Google API key. This key tells Google who you are, presumably so it can keep track of rate limits and such things. To create an API key, follow the instructions in the documentation. Once you have an API key, pass it to gmaps before creating widgets:

gmaps.configure(api_key="AI...")

Documentation

Documentation for gmaps is available here.

Similar libraries

The current version of this library is inspired by the ipyleaflet notebook widget extension. This extension aims to provide much of the same functionality as gmaps, but for leaflet maps, not Google maps.

Issue reporting and contributing

Report issues using the github issue tracker.

Contributions are welcome. Read the CONTRIBUTING guide to learn how to contribute.

gmaps's People

Contributors

carolinux avatar fwahl711 avatar npmcdn-to-unpkg-bot avatar pbugnion avatar xoolive avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.