def locator(location): gmaps = googlemaps.Client('Enter Secret pass key here') response1 = gmaps.places('Hospital', location) i = 1 hospitalresponse = 'n' if response1['status'] == 'OK': hospitals = response1['results'] for hospital in hospitals: i += 1 if hospitalresponse == 'n': print "Send All possible details to ", hospital['name'] print "Waiting for Response from hospital..." hospitalresponse = raw_input("Enter Response(n/y):") hospitalresponse = hospitalresponse.lower() if hospitalresponse == 'y': hospositive = hospital['name'] else: print "Accident occured at lat,long,destination. Charge :", hospositive, "to", hospital[ 'name'] response2 = gmaps.places('Police Station', location) if response2['status'] == 'OK': Policestations = response2['results'] for policestation in Policestations: print "Send Accident details including Latitude and Longitude,geocode_result,hospital in charge, Impact Quotient etc to", policestation[ 'name'] break
def find_banking_services(query, location, bank_type, radius, api_key): gmaps = googlemaps.Client(key=api_key) banking_places = gmaps.places(query, location=location, type=bank_type, radius=radius) locations = [] for bank in banking_places['results'][0:9]: locations.append([bank['name'], bank['formatted_address']]) return locations
def locator_latloninput(): gmaps = googlemaps.Client('AIzaSyCdyV5Olz8kyrCTlgnvNF-Mud9Mp3jtBMU') lat = input("Enter the Latitude:") lon = input("Enter the longitude:") destination = gmaps.reverse_geocode((40.714224, -73.961452)) locator(get_location(destination[0]))
def gmap_call(address, key): gmaps = googlemaps.Client(key=key) address = address result = gmaps.geocode(address) for item in result[0]['address_components']: if item["types"][0] == 'postal_code': zipcode = item['short_name'] return zipcode
def get_gmaps(): maps_key = "AIzaSyC4N2CrBVCXL9IXAJJim-Rn5xLM3sl-d2s" # Restricted key, can only be run from my server. return googlemaps.Client(key=maps_key)
dias_dict = { 'SEG': 'Segunda', 'TER': u'Terça', 'QUA': 'Quarta', 'QUI': 'Quinta', 'SEX': 'Sexta', 'SAB': U'Sábado', 'DIARIA': u'Diária', 'DIÁRIA': u'Diária', } """ ENDEREÇO(NOME, NOME_MIN, NOME_CSV, BAIRRO, LAT, LONG) SETOR(ID, FREQUÊNCIA) COLETA(ID, NOME_ENDERECO, SETOR_ID, NUM_ROTA) HORARIO(TURNO, INTERVALO) COLETA_HORARIO(ID_COLETA, INTERVALO) """ if __name__ == '__main__': inicio = datetime.now() gmaps = googlemaps.Client(key=GOOGLE_API_SECRET_KEY) with codecs.open(STATIC_DIR + '\\recrecife\\csv\\roteirizacao.csv', 'r', 'utf-8') as f: f.next() counter = 0 not_found = 0 for line in f: line = line.split(';')
from __future__ import print_function # In python 2.7 from geopy.distance import vincenty from geopy.distance import great_circle from flask import Flask, render_template, request from math import radians, cos, sin, asin, sqrt from googlemaps import googlemaps import json import logging import sys import csv import pprint import math DEBUG = 'INFO' gmaps = googlemaps.Client("AIzaSyDqlY2dyOTrvcYWBtvsibdsetN14fJcnL4") app = Flask(__name__) pp = pprint.PrettyPrinter(indent=2) globalLong = -87.628858 globalLat = 41.883734 # Get csv data crime_csv = 'datasets/crimefinal.csv' hos_csv = 'datasets/hosfinal.csv' libraries_csv = 'datasets/librariesfinal.csv' school_csv = 'datasets/schoolfinal.csv' parks_csv = 'datasets/parksfinal.csv' csv_paths = [crime_csv, hos_csv, libraries_csv, school_csv, parks_csv] ########### # HELPERS #
else: latitude, longitude = None, None print query, "<no results>" return latitude, longitude global smallest smallest = 20036 def find_closest(garage_lon, garage_lat, place_id): global closest_garage global smallest distance = haversine(my_lon, my_lat, garage_lon, garage_lat) if distance < smallest: smallest = distance closest_garage = place_id gmaps = googlemaps.Client('AIzaSyBDZ-1yXXKyUJdodrsbsR4Um_XQcbhz4GU') address = '47, South Bhopa Road, New Mandi, Muzaffarnagar, Uttar Pradesh, India' my_lat , my_lon = get_coordinates(address) print my_lat, my_lon google_places = GooglePlaces('AIzaSyBDZ-1yXXKyUJdodrsbsR4Um_XQcbhz4GU') local = google_places.nearby_search(location=address, keyword='Car Mechanic', radius=20000) #local = gmaps.nearby_search('cafe near ' + address) #print local.html_attributions #all_stations = (local.places).json()['items'] print local.places for place in local.places: print place.name print '\n' print place.geo_location['lat']
def convert_address_to_lat_lon(address, api_key): gmaps = googlemaps.Client(key=api_key) lat = gmaps.geocode(address)[0] return (lat['geometry']['location']['lat'], lat['geometry']['location']['lng'])
# #### Get API key - stored in file name: gm-config.config # In[8]: # get api key from file - no, github, you can't have my api key apikey_path = "C:/Users/Jonathan/Google Drive/" with open(apikey_path + 'gm_config.config', 'r') as f: api_key = f.readline() api_key = api_key.strip() # In[115]: gmaps = googlemaps.Client(key=api_key) address = 'Constitution Ave NW & 10th St NW, Washington, DC' lat= gmaps.geocode(address)[0] lat # In[83]: lat_long = dict([]) lat['geometry']['location'] lat_long = (lat['geometry']['location']['lat'], lat['geometry']['location']['lng']) # In[85]: lat_long
from googlemaps import googlemaps import apikey import json import math import android,time,datetime droid = android.Android() gmaps = googlemaps.Client(key=apikey.key()) departure = "40 Saint George Street Toronto, ON M5S 2E4 Canada" destination = "349 College Street Toronto, ON M5T 1S5 Canada" # departure = raw_input("departure: ") # destination = raw_input("destination: ") # Variables k_constant = 0.1 target_angle = -2 # PLACEHOLDER -the target angle that we want the servo to point at current_angle = 0 # PLACEHOLDER - the current best estimate of where the servo is pointing current_velocity = 0 time_length_of_iteration = 1/10 geofencing_radius = 10 # In Metres last_heading = 0 # Initialize waypoints routes = gmaps.directions(departure, destination, mode = "walking") steps = routes[0]['legs'][0]['steps'] waypoints = map(lambda waypoint: waypoint['start_location'], steps) waypoints.append(steps[-1]['end_location']) # Methods def get_angular_displacement(target_coord, current_coord, displacement_vector):
import random from flask import Flask, jsonify, request from flask_restful import Resource from flask_cors import CORS from firebase import firebase import requests from bs4 import BeautifulSoup import json from googlemaps import googlemaps # to use for geocoding gmaps = googlemaps.Client(key="AIzaSyD8W5OzuAhjzrtbQGMpd5UUZpekdOUG5cI") #------ for getting the json object ------------------ # using the source instead of open source = requests.get('https://mlh.io/seasons/na-2019/events').text soup = BeautifulSoup(source, 'lxml') mlh_json = open("mlh.json", "w") mlh_json.write( #beginning "[") divs = soup.find_all('div', class_='event-wrapper') i = 0 for div in divs: i += 1
from pymongo import MongoClient from googlemaps import googlemaps import re key_file = open('/root/snoopy/maps_key.txt') maps_key = re.sub('\n', '', key_file.readline()) assert maps_key, 'Maps API key required to run!' client = MongoClient('mongodb', 27017) db = client.snoopy logs = db.police_logs gmaps_client = googlemaps.Client(key=maps_key) missing_lookup = {'maps_geocode': {'$exists': False}, 'address': {'$exists': True}} log_entries = logs.find(missing_lookup) for key, entry in enumerate(log_entries): print(entry[u'address']) geocode_result = gmaps_client.geocode(entry[u'address'] + ", San Luis Obispo, California") print(geocode_result) if geocode_result: print("going to update") print(geocode_result) logs.update({u'_id': entry[u'_id']}, {'$set': {'maps_geocode': geocode_result}}, upsert=True)