Chloe  Butler

Chloe Butler

1650246915

Gmaps: Google Maps for Jupyter Notebooks

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:

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

# load a Numpy array of (latitude, longitude) pairs
locations = gmaps.datasets.load_dataset("taxi_rides")

fig = gmaps.figure()
fig.add_layer(gmaps.heatmap_layer(locations))
fig

docs/source/_images/taxi_example.png

We can also plot chloropleth maps using GeoJSON:

from matplotlib.cm import viridis
from matplotlib.colors import to_hex

import gmaps
import gmaps.datasets
import gmaps.geojson_geometries

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

countries_geojson = gmaps.geojson_geometries.load_geometry('countries') # Load GeoJSON of countries

rows = gmaps.datasets.load_dataset('gini') # 'rows' is a list of tuples
country2gini = dict(rows) # dictionary mapping 'country' -> gini coefficient
min_gini = min(country2gini.values())
max_gini = max(country2gini.values())
gini_range = max_gini - min_gini

def calculate_color(gini):
    """
    Convert the GINI coefficient to a color
    """
    # make gini a number between 0 and 1
    normalized_gini = (gini - min_gini) / gini_range

    # invert gini so that high inequality gives dark color
    inverse_gini = 1.0 - normalized_gini

    # transform the gini coefficient to a matplotlib color
    mpl_color = viridis(inverse_gini)

    # transform from a matplotlib color to a valid CSS color
    gmaps_color = to_hex(mpl_color, keep_alpha=False)

    return gmaps_color

# Calculate a color for each GeoJSON feature
colors = []
for feature in countries_geojson['features']:
    country_name = feature['properties']['name']
    try:
        gini = country2gini[country_name]
        color = calculate_color(gini)
    except KeyError:
        # no GINI for that country: return default color
        color = (0, 0, 0, 0.3)
    colors.append(color)

fig = gmaps.figure()
gini_layer = gmaps.geojson_layer(
    countries_geojson,
    fill_color=colors,
    stroke_color=colors,
    fill_opacity=0.8)
fig.add_layer(gini_layer)
fig

docs/source/_images/geojson-2.png

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

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

df = gmaps.datasets.load_dataset_as_df('starbucks_kfc_uk')

starbucks_df = df[df['chain_name'] == 'starbucks']
starbucks_df = starbucks_df[['latitude', 'longitude']]

starbucks_layer = gmaps.symbol_layer(
    starbucks_df, fill_color="green", stroke_color="green", scale=2
)
fig = gmaps.figure()
fig.add_layer(starbucks_layer)
fig

docs/source/_images/starbucks-symbols.png

Installation

Installing jupyter-gmaps with conda

The easiest way to install gmaps is with conda:

$ conda install -c conda-forge gmaps

Installing jupyter-gmaps with pip

Make sure that you have enabled ipywidgets widgets extensions:

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

You can then install gmaps with:

$ pip install gmaps

Then tell Jupyter to load the extension with:

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

Installing jupyter-gmaps for JupyterLab

To use jupyter-gmaps with JupyterLab, you will need to install the jupyter widgets extension for JupyterLab:

$ jupyter labextension install @jupyter-widgets/jupyterlab-manager

You can then install jupyter-gmaps via pip (or conda):

$ pip install gmaps

Next time you open JupyterLab, you will be prompted to rebuild JupyterLab: this is necessary to include the jupyter-gmaps frontend code into your JupyterLab installation. You can also trigger this directly on the command line with:

$ jupyter lab build

Support for JupyterLab pre 1.0

To install jupyter-gmaps with versions of JupyterLab pre 1.0, you will need to pin the version of jupyterlab-manager and of jupyter-gmaps. Find the version of the jupyterlab-manager that you need from this compatibility table. For instance, for JupyterLab 0.35.x:

$ jupyter labextension install @jupyter-widgets/jupyterlab-manager@0.38

Then, install a pinned version of jupyter-gmaps:

$ pip install gmaps==0.8.4

You will then need to rebuild JupyterLab with:

$ jupyter lab build

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.

Vision and roadmap

Jupyter-gmaps is built for data scientists. Data scientists should be able to visualize geographical data on a map with minimal friction. Beyond just visualization, they should be able to integrate gmaps into their widgets so they can build interactive applications.

We see the priorities of gmaps as:

  • responding to events, like user clicks, so that maps can be used interactively.
  • adding greater flexibility and customisability (e.g. choosing map styles)

Issue reporting and contributing

Report issues using the github issue tracker.

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


Author: pbugnion
Source Code: https://github.com/pbugnion/gmaps
License: View license

#python #jupyter 

What is GEEK

Buddha Community

Gmaps: Google Maps for Jupyter Notebooks
Mitchel  Carter

Mitchel Carter

1603627200

Google Maps Location Sharing Not Updating

In this blog post, I will discuss how to fix google maps location sharing not updating or not working and also will unable to refresh Google maps sharing location issues. By using Google location sharing features you can choose who can find your current location for what length of time. It is important to show the updated location that you can share with your family or friends so that they can receive you or show you the right path to access at your right location simply.

Why is Google Maps Location Sharing Not Updating?

In our day to day life, we use it a lot to find places, explore businesses, and share locations with friends. However, In addition to these, sometimes Google maps also experience one major issue that is “Google maps location sharing not working”. Find the below list of solutions to resolve the issue:-

Solution 1: Check your Wi-Fi or Cellular Signal

Make sure that you have the proper internet connection available on a device that you are using to use Google Maps. You can also switch to the cellular data from your Wi-Fi connection.

Solution 2: Update Google Maps app

Using an outdated Google Maps app version may cause plenty of technical issues and you can easily resolve this issue after updating your app to the latest version.

Solution 3: Restart your device

It is one of the best solutions to resolve all kinds of Google Maps related issues. You can easily access the Google Maps app after restarting your preferred device.

Why can’t I refresh someone’s location on Google Maps?

It’s another issue among the users that Google Maps stopped location sharing refreshing. There could be plenty of reasons for this problem. Some of the most common issues of this problem listed below:-

  • Improper internet connectivity.
  • Outdated app version.
  • Caches and data.
  • Compatibility issues.
  • Using the incompatible device.
  • Network connection issues.
  • Calibration issues.

References: How to share real-time location with others

Conclusion

I hope you liked this article on Why google maps location sharing not updating, and google maps location sharing not working. I would like to have feedback from my blog readers. Your valuable feedback, question, or comments about this article are always welcome.

#google maps api #google maps location sharing not updating #google maps location sharing not working #google maps location sharing unable to refresh

Google Maps Draggable Marker Get Coordinates

In this blog post, you will learn how to create google maps draggable marker using Google Maps Javascript API v3, and when you drag the marker position then get coordinates (latitude and longitude) of that location where you place the marker.

How to make a marker draggable?

To allow users to drag a marker to a different location on the map, set the draggable attribute to true in the marker options.

var myLatlng = new google.maps.LatLng(-25.363882,131.044922);
var mapOptions = {
  zoom: 4,
  center: myLatlng
}
var map = new google.maps.Map(document.getElementById("map"), mapOptions);
// Place a draggable marker on the map
var marker = new google.maps.Marker({
    position: myLatlng,
    map: map,
    draggable:true,
    title:"Drag me!"
});

#google maps api #javascript #draggable marker google maps v3 example #google maps draggable marker #google maps draggable marker get coordinates

Google's TPU's being primed for the Quantum Jump

The liquid-cooled Tensor Processing Units, built to slot into server racks, can deliver up to 100 petaflops of compute.

The liquid-cooled Tensor Processing Units, built to slot into server racks, can deliver up to 100 petaflops of compute.

As the world is gearing towards more automation and AI, the need for quantum computing has also grown exponentially. Quantum computing lies at the intersection of quantum physics and high-end computer technology, and in more than one way, hold the key to our AI-driven future.

Quantum computing requires state-of-the-art tools to perform high-end computing. This is where TPUs come in handy. TPUs or Tensor Processing Units are custom-built ASICs (Application Specific Integrated Circuits) to execute machine learning tasks efficiently. TPUs are specific hardware developed by Google for neural network machine learning, specially customised to Google’s Machine Learning software, Tensorflow.

The liquid-cooled Tensor Processing units, built to slot into server racks, can deliver up to 100 petaflops of compute. It powers Google products like Google Search, Gmail, Google Photos and Google Cloud AI APIs.

#opinions #alphabet #asics #floq #google #google alphabet #google quantum computing #google tensorflow #google tensorflow quantum #google tpu #google tpus #machine learning #quantum computer #quantum computing #quantum computing programming #quantum leap #sandbox #secret development #tensorflow #tpu #tpus

Rodrigo Senra - Jupyter Notebooks

Nosso convidado de hoje é diretor técnico na Work & Co, PhD em Ciências da Computação, já contribuiu com inúmeros projetos open source em Python, ajudou a fundar a Associação Python Brasil e já foi premiado com o Prêmio Dorneles Tremea por contribuições para a comunidade Python Brasil.

#alexandre oliva #anaconda #apache zeppelin #associação python brasil #azure notebooks #beakerx #binder #c++ #closure #colaboratory #donald knuth #fernando pérez #fortran #graphql #guido van rossum #ipython #java #javascript #json #jupyter kenels #jupyter notebooks #jupyterhub #jupyterlab #latex #lisp #literate programming #lua #matlab #perl #cinerdia #prêmio dorneles tremea #python #r #rodrigo senra #scala #spark notebook #tcl #typescript #zope

Reid  Rohan

Reid Rohan

1644354720

Gmaps: The easiest way to use Google Maps

Important

If you're developer, I'm moving gmaps.js to NPM, you can give your opinion and check the migration progress in Issue #404


gmaps.js - A Javascript library that simplifies your life

gmaps.js allows you to use the potential of Google Maps in a simple way. No more extensive documentation or large amount of code.

Visit the examples in hpneo.github.com/gmaps Go to the API Documentation hpneo.github.io/gmaps/documentation.html

Quick Start

  1. Add a reference to Google Maps API
  2. Add gmaps.js in your HTML
  3. Enjoy!
<!DOCTYPE html>
<html>
<head>
  <title></title>
  <script src="http://maps.google.com/maps/api/js"></script>
  <script src="gmaps.js"></script>
  <style type="text/css">
    #map {
      width: 400px;
      height: 400px;
    }
  </style>
</head>
<body>
  <div id="map"></div>
  <script>
    var map = new GMaps({
      el: '#map',
      lat: -12.043333,
      lng: -77.028333
    });
  </script>
</body>
</html>

Use with AMD

With require.js, you need to load Google Maps JavaScript API first. For example, assuming you have a googlemapsapi.js file:

define(['async!http://maps.google.com/maps/api/js?v=3&sensor=false'], function() {});

Next you have to define the dependency for gmaps.js:

require.config({
  paths: {
    "googlemapsapi": "googlemapsapi",
  },
  shim: {
    gmaps: {
      deps: ["googlemapsapi"],
      exports: "GMaps"
    }
  }
});

Also, you can use the googlemaps-amd plugin.

Build

If you would like to build gmaps from source run the following at the terminal:

git clone https://github.com/HPNeo/gmaps.git
cd gmaps
npm install
grunt

Changelog

0.4.25

  • Change findAbsolutePosition (see #494)

0.4.24

  • Fix bug in getRoutes (see #373)

0.4.23

  • Fix bug at trying to remove a large amount of markers inside a marker cluster (see #473)
  • Check for Google Maps library before creating a GMaps object (see #467)
  • Check the Google Maps API at instantiation instead of declaration (see #467)
  • Add polyfill for google.maps.Rectangle.prototype.containsLatLng

0.4.22

  • Render directions
  • Added missing function for registering addListenerOnce

0.4.21

  • Better check for console.error

0.4.20

  • Show an error in the console, instead throwing an error

0.4.19

  • Fix bug at hiding markers' context menu when the map is zooming

0.4.18

  • Fix bug in array_map

0.4.17

  • Remove the http so the library (Google Maps call) will also work under SSL without warnings
  • Update route drawing methods to allow 'icons' option for drawPolyline
  • Remove dependency on 'grunt-cli' having to be installed globally

0.4.16

  • Fix removeMarkers

0.4.15

  • Add overlay to mouseTarget when click event is set
  • addControl/createControl now accepts HTML elements or HTML strings
  • Add containsLatLng to google.maps.Circle

0.4.14

  • Fix bug in drawPolygon
  • Hide context menu before the zoom is changed

0.4.13

  • Allow unitSystem setting in travelRoute
  • Add functionality to remove controls
  • Delegates non custom events to google.map
  • Convert featureType and elementType toLowerCase in static maps

0.4.12

  • Adds ability to listen for clicks on overlays

0.4.11

  • Add RadarSearch to the places layer
  • Update default control styles to match new Google Maps release.

0.4.10

  • Fix and optimize removeMarkers
  • Fix bug in addMarker (issue #270)

0.4.9

  • Add UMD support (AMD, CommonJS, browser globals)
  • Add retina support
  • FitZoom only use visible markers

0.4.8

  • Fix getRoutes

0.4.7

  • Add callback for failure in getRoutes
  • Update marker clusterer after remove marker
  • Add support for string arrays to arrayToLatLng

0.4.6

  • Allow initialising GMaps without new
  • Added styled map support for static maps
  • Fixed name display for styled maps
  • Allow no zoom for static map request

0.4.5

  • Fix IE8 bug using array_map
  • Add Grunt and Bower support

0.4.4

  • Fix buildContextMenu reference in addMarker

0.4.3

  • Fix removePolylines and removePolygons

0.4.2

  • Fix drawSteppedRoute

0.4.1

  • Fix fitZoom

0.4.0

  • Split gmaps.js in modules

0.3.5

  • Enable new Google Maps style

0.3.4

  • Add support for context menu in multiple maps

0.3.3

  • Fix destination as address in getRoutes

0.3.2

  • Support for removing Fusion Tables and GeoRSS/KML layers with removeLayer

0.3.1

  • Improve event binding at adding markers, polylines or polygons

0.3

  • Add native events to google.maps objects and custom events to GMaps maps
  • Check for Google Maps library and defined element when initialize
  • Allow route origins to be a string or array

0.2.31

  • Fix context menu position bug

0.2.30

  • New feature: StreetView Panoramas

0.2.29

  • New methods: removePolyline and removePolygon
  • Tests for Styled MapTypes

0.2.28

  • Test suite
  • Fix double event firing bug

0.2.27

  • Allow create context menus for markers

0.2.26

  • Fix bug in getElevations
  • Rename fitBounds to fitLatLngBounds

0.2.25

  • Support for GeoJSON in drawPolygon
  • Use 'complete' instead of 'always' in GMaps.geolocate

0.2.24

  • New feature: Overlay Map Types

0.2.23

  • Add full support to google.maps.PolylineOptions
  • New method: removeMarker

0.2.22

  • New feature: Map Types

0.2.21

  • Support to add google.maps.Marker objects in addMarker and addMarkers methods.

0.2.20

  • Add support for other HTML block elements instead "div" (like "section").

0.2.19

  • Use MarkerClusterer to group markers

0.2.18

  • Check if GMaps is defined before load extensions

0.2.17

  • Fix bug with disableDefaultUI option in constructor

0.2.16

  • Fix another bug in createMarker

0.2.15

  • Fix bug in createMarker

0.2.14

  • Adding IDs, classes and innerHTML to createControl. (Note: Use 'content' instead 'text' in createControl)

0.2.13

  • Add support for Places library in addLayer

0.2.12

  • Fix map events without MouseEvent object
  • Fix bug in drawCircle and drawRectangle
  • Fix bug in zoomIn and zoomOut
  • New methods: removePolygon and removePolygons

0.2.11

  • Add support to Panoramio in addLayer

0.2.10

  • New method: toImage

0.2.9

  • Extend the drawSteppedRoute and travelRoute functions

0.2.8

  • New feature: Layers

0.2.7

  • New method: removeRoutes
  • Access all native methods of google.maps.Map class

0.2.6

  • Support for multiple overlays

0.2.5

  • Add support to all marker events
  • Add support for animations at show and remove overlays

0.2.4.1

  • Create GMaps class only when Google Maps API is loaded

0.2.4

  • New feature: Elevation service

0.2.3

  • New method: getZoom

0.2.2

  • Minor improvements to support Backbone.js
  • Fix controls position

0.2.1

  • More default values in GMaps constructor.

0.2

  • Remove jQuery dependency.

0.1.12.5

  • New method "removePolylines" and alias "cleanRoute"

0.1.12.4

  • New methods: fitZoom and fitBounds

0.1.12.3

  • New method: refresh

0.1.12.2

  • New options in GMaps constructor: width and height

0.1.12.1

  • New methods: loadFromFusionTables and loadFromKML

0.1.12

  • New feature: KML and GeoRSS
  • Fix bug in getFromFusionTables

0.1.11

  • New feature: Fusion Tables

0.1.10

  • New feature: Custom controls

0.1.9

  • New feature: Static maps

0.1.8.10

  • Better GMaps.Route methods

0.1.8.9

  • Fix typo in Polyline events
  • Add InfoWindow events

0.1.8.8

  • Add Polyline events

0.1.8.7

  • Add drag and dragstart events to Marker

0.1.8.6

  • Add avoidHighways, avoidTolls, optimizeWaypoints, unitSystem and waypoints options in getRoutes
  • New method: createMarker

0.1.8.5

  • geolocation and geocode methods are static now (using them with GMaps.geolocation and GMaps.geocode)

0.1.8.4

  • Fix typo in geocode method
  • Allow all MapOptions in constructor (see 'MapOptions' section in Google Maps API Reference)

0.1.8.3

  • Add pane option ('floatPane', 'floatShadow', 'mapPane', 'overlayImage', 'overlayLayer', 'overlayMouseTarget', 'overlayShadow') in drawOverlay
  • New methods: removeOverlay and removeOverlays

0.1.8.2

  • Change pane ('floatPane' to 'overlayLayer') in drawOverlay

0.1.8.1

  • Fix bug in drawCircle

0.1.8

  • New feature: Overlays
  • New method: drawCircle

0.1.7.1

  • Bug fix: zoomIn/zoomOut can change zoom by argument
  • New method: setZoom

0.1.7

  • New class: GMaps.Route

0.1.6

  • New feature: Geofence (with markers)
  • New method: drawPolygon
  • Bug fix: Change reserved word in Context menu

0.1.5

  • New feature: Geocoding
  • New method: drawSteppedRoute (similar to travelRoute)

0.1.4

  • New events in addMarker
  • Add step_number property in travelRoute method

0.1.3

  • New feature: Context menu (for map and marker only)
  • New method: travelRoute
  • Change setCenter to panTo in GMaps setCenter method
  • Save entire route data in routes array (instead saving only route path)
  • Context menu and Route example (using travelRoute)

0.1.2

  • drawPolyline can accept both an array of LatLng objets or an array of coordinates
  • New methods: getRoutes and drawRoute
  • Route example

0.1.1

  • Rename drawRoute method to drawPolyline (more accurate)
  • Marker example

0.1 - Initial release

  • Map events
  • Geolocation
  • Add Markers
  • Marker infoWindows
  • Draw routes and circles
  • Initial examples

License

MIT License. Copyright 2014 Gustavo Leon. http://github.com/hpneo

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Author: HPNeo
Source Code: https://github.com/HPNeo/gmaps 

#javascript #google-maps #maps