How to use the googlemaps.Client function in googlemaps

To help you get started, we’ve selected a few googlemaps examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github googlemaps / google-maps-services-python / test / View on Github external
def test_clientid_not_accepted(self):
        client = googlemaps.Client(client_id="asdf", client_secret="asdf")

        with self.assertRaises(ValueError):
github googlemaps / google-maps-services-python / test / View on Github external
def test_auth_url_with_channel(self):
        client = googlemaps.Client(key="AIzaasdf",

        # Check ordering of parameters + signature.
        auth_url = client._generate_auth_url("/test",
                                             {"param": "param"},
        self.assertEqual(auth_url, "/test?param=param"

        # Check if added to requests to API with accepts_clientid=False
        auth_url = client._generate_auth_url("/test",
                                             {"param": "param"},
github googlemaps / google-maps-services-python / test / View on Github external
def setUp(self):
        self.key = "AIzaasdf"
        self.client = googlemaps.Client(self.key)
github peeringdb / peeringdb / peeringdb_server / management / commands / View on Github external
def handle(self, *args, **options):
        self.commit = options.get("commit", False)
        reftag = options.get("reftag")
        limit = options.get("limit")
        if reftag.find(".") > -1:
            reftag, _id = reftag.split(".")
            _id = 0
        self.gmaps = googlemaps.Client(API_KEY, timeout=5)
        self.sync(reftag, _id, limit=limit)
github FoglyOgly / Meowth / meowth / exts / map / View on Github external
from pytz import timezone
import io
import codecs
from math import radians, degrees, sqrt, ceil
import csv
from urllib.parse import quote_plus
import googlemaps
import re
import requests
from typing import List
import tempfile

from .map_info import gmaps_api_key
from .errors import *

gmaps = googlemaps.Client(key=gmaps_api_key)

class ReportChannel():
    def __init__(self, bot, channel): = bot = channel

    def __eq__(self, other):
        return ==

    def _data(self):
        channel_query ='report_channels').query()
        _data = channel_query.where(
        return _data
github mricon / ingress-fieldplan / lib / View on Github external
# Do we have a gmaps key?
    if gmapskey is None:
        # Do we have a cached copy in the cache?
        if 'clientkey' in _gmap_cache_db:
            gmapskey = _gmap_cache_db['clientkey']
        # save it in the cache db if not present or different
        if 'clientkey' not in _gmap_cache_db or _gmap_cache_db['clientkey'] != gmapskey:
  'Caching google maps key for future lookups')
            _gmap_cache_db['clientkey'] = gmapskey

    gmaps = None
    if gmapskey:
        import googlemaps
        gmaps = googlemaps.Client(key=gmapskey)'Generating the distance matrix using Google Maps API, may take a moment')
    else:'Generating the distance matrix')

    a = combined_graph.copy()
    n = a.order()
    logger.debug('n=%s', n)

    # We consider any direct distance shorter than 40m as effectively 0,
    # since the agent doesn't need to travel to access both portals.
    for p1 in range(n):
        matrow = list()
        matrow_dur = list()
        direct_matrow = list()
        for p2 in range(n):
            # Do direct distance first
github all-of-us / raw-data-repository / rest-api / tools / View on Github external
def _get_lat_long_for_site(self, address_1, city, state):
    self.full_address = address_1 + ' ' + city + ' ' + state
      self.api_key = os.environ.get('API_KEY')
      self.gmaps = googlemaps.Client(key=self.api_key)
        geocode_result = self.gmaps.geocode(address_1 + '' +  city + ' ' +  state)[0]
      except IndexError:
        self.errors.append('Bad address for {}, could not geocode.'.format(self.full_address))
        return None, None
      if geocode_result:
        geometry = geocode_result.get('geometry')
        if geometry:
          location = geometry.get('location')
        if location:
          latitude = location.get('lat')
          longitude = location.get('lng')
          return latitude, longitude
          logging.warn('Can not find lat/long for %s', self.full_address)
          self.errors.append('Can not find lat/long for {}'.format(self.full_address))
github tomslee / airbnb-data-collection / View on Github external
def reverse_geocode(config, location):
    Return address information from the Google API as a Location object for a given lat lng
    gmaps = googlemaps.Client(key=config.GOOGLE_API_KEY)
    # Look up an address with reverse geocoding
    # lat = 41.782
    # lng = -72.693
    lat = location.lat_round
    lng = location.lng_round
    results = gmaps.reverse_geocode((lat, lng))

    # Parsing the result is described at

    json_file = open("geocode.json", mode="w", encoding="utf-8")
    json_file.write(json.dumps(results, indent=4, sort_keys=True))
    #  In practice, you may wish to only return the first result (results[0])

    for result in results:
github uno-isqa-8950 / uno-cpi / projects / View on Github external
from django.forms import inlineformset_factory, modelformset_factory
from .filters import SearchProjectFilter
import googlemaps
from shapely.geometry import shape, Point
import pandas as pd
import json
from django.db.models import Sum
import datetime
from django.conf import settings
from googlemaps import Client
# The imports below are for running sql queries for AllProjects Page
from django.db import connection
from UnoCPI import sqlfiles

gmaps = Client(key=settings.GOOGLE_MAPS_API_KEY)

def communitypartnerhome(request):
    usertype = User.objects.get(is_communitypartner=True)

#    if usertype.is_communitypartner == True:
    return render(request, 'community_partner_home.html',
                  {'communitypartnerhome': communitypartnerhome,'usertype':usertype})

def myProjects(request):