def geocode_facility(geo_facility_dict: dict, client: googlemaps.Client) -> dict: street_address = format_street_address(geo_facility_dict) print(f"geocoding: {street_address}") try: geocode_result = client.geocode(street_address) except googlemaps.exceptions.Timeout: geocode_result = client.geocode(street_address) if len(geocode_result) == 1: geo_facility_dict['formatted_address'] = geocode_result[0][ 'formatted_address'] geo_facility_dict['google_place_id'] = geocode_result[0]['place_id'] geo_facility_dict['google_location'] = { 'lat': geocode_result[0]['geometry']['location']['lat'], 'lon': geocode_result[0]['geometry']['location']['lng'] } else: geo_facility_dict['formatted_address'] = '' geo_facility_dict['google_place_id'] = '' geo_facility_dict['google_location'] = {} geo_facility_dict['location'] = { 'lat': geo_facility_dict['latitude'], 'lon': geo_facility_dict['longitude'] } return geo_facility_dict
def get_lat_long(self): gmaps = Client(key=settings.GMAPS_API_KEY) results = gmaps.geocode(address=self.address + ", " + self.city, region="CA") if results: lat_lng = results[0]['geometry']['location'] return lat_lng
def geocode_addresses(df, api_key: Optional[str] = None): """Geocode addresses in a dataframe. Args: df (DataFrame): A DataFrame containing the addresses to geocode. Returns: (DataFrame): Returns the DataFrame with geocoded latitudes and longitudes. """ if api_key is None: api_key = get_google_maps_api_key() gmaps = Client(key=api_key) for index, item in df.iterrows(): # TODO: Handle existing lat and long more elegantly. # try: # if item.latitude and item.longitude: # continue # except: # pass address = f'{item.street}, {item.city}, {item.state} {item.zip}' geocode_result = gmaps.geocode(address) if geocode_result: df.at[index, 'formatted_address'] = geocode_result[0]['formatted_address'] location = geocode_result[0]['geometry']['location'] print(item.name, '-->', location) df.at[index, 'latitude'] = location['lat'] df.at[index, 'longitude'] = location['lng'] # TODO: Round latitude and longitude (4-6 decimal places?) for info in geocode_result[0]['address_components']: key = info['types'][0] if key == 'administrative_area_level_2': df.at[index, 'county'] = info['long_name'] sleep(.2) # Prevents spamming Google's servers (necessary?). return df
def getCoord(address): """ Get coordinates for location using Google Maps Geolocation API. Raises: serializers.ValidationError: Google Maps API could not find pair of coordinates suitable for address passed as input. Returns: dictionary: Geocoding information. """ start_time = time.time() gmaps = GoogleMaps(os.getenv("GOOGLE_KEY")) geocode_result = gmaps.geocode(address) data = {'long': {}, 'short': {}, 'location': {}} if geocode_result: for geolist in geocode_result: for item in geolist['address_components']: for category in item['types']: data['long'].update([(category, item['long_name'])]) data['short'].update([(category, item['short_name'])]) data['location'] = geolist['geometry']['location'] else: e = serializers.ValidationError('GeoCoding Error: Could not parse coordinates') capture_message(e) raise e print('--- Tiempo de ejecucion getCoord: {} segundos ---'.format((time.time() - start_time))) return data
def lookup_location(client: Client, location: str, throttle_sec: Optional[float] =None) -> List[DictAny]: # Not clear what errors can occur here at the GCP level log.debug(f"Looking up Location {location}") result: List[DictAny] = client.geocode(location) if throttle_sec is not None: time.sleep(throttle_sec) return result
class MapSearch(): def __init__(self, key=''): self.key = key self.lat = None self.lng = None self.country = '' self.is_us = False self.json = None if not self.key: raise AssertionError("There was no API keys specified.") self.client = GClient(key=self.key) # returns all of the data from the location def search_address(self, location="Akron, Ohio"): self.json = safe_list_get(self.client.geocode(location), 0) components = self.json['address_components'] for thing in components: if 'country' in thing['types']: self.country = thing['long_name'] self.is_us = ('US' in thing['short_name']) self.lat = self.json['geometry']['location']['lat'] self.lng = self.json['geometry']['location']['lng'] return self.json # returns the coordinates def get_coordinates(self, location="Kansas City, MO"): self.search_address(location) return self.lat, self.lng
class Maps(): def __init__(self,key): self.key=key self.con = Client(key=self.key) def getDirections(self,origin,destination,mode='walking'): r,a=self.con.directions(origin,destination,mode=mode)[0]['legs'][0]['steps'],[] for i in r: a.append(i['html_instructions']) return a def textToLatLng(self,text): r=self.con.geocode(text,language='ES-MX')[0]['geometry']['location'] return '%s,%s'%(r['lat'],r['lng']) def getReferenceOnLocation(self,latLngAsString): lat,lng=latLngAsString.split(',') nearbyS='$MAPS_API?key=%s&location=%s&rankby=distance'%(self.key,latLngAsString) return json.loads(requests.get(nearbyS).text)['results'][0]['name'] def getKeyWords(self,string,start='<b>',end='</b>'): words=[] for i in (lambda x:(i for i in xrange(0,x.count(start))))(string): string=string[string.find(start)+3:] words.append(string[:string.find(end)]) return words def getRouteLine(self,line,route=None, stop=None): k = self.getKeyWords(line) if route and stop: return 'Continua hasta %s y abordas la ruta %s en la %s '%(k[0], route, stop) elif stop: return 'Desciende en la %s'%stop else: if len(k)>2: return 'Voltea hacia el %s, camina desde %s hacia %s '%(k[0],k[1],k[2]) else: return 'Dirigete hacia %s '%k[0]
def get_lat_long(self, location): gmaps = Client(key='AIzaSyADU4JlRIaly445PDXwCpBUs8Mq5tZsndo') geocode_result = gmaps.geocode(location) lat_long = {} lat_long["latitude"] = geocode_result[0]['geometry']['location']['lat'] lat_long["longitude"] = geocode_result[0]['geometry']['location']['lng'] return lat_long
def set_google_maps_fields(self, latlng=None, calls=True): """ Uses the Google Maps API to set: - geocoded latlng - nearest school name + distance - nearest train station name + distance """ client = Client(key=settings.GOOGLE_MAPS_API_SERVER_KEY) if not latlng: data = client.geocode(self.address) if not data: raise Exception("Unable to resolve the address: '%s'" % address) latlng = data[0]["geometry"]["location"] self.point = GEOSGeometry("POINT(%(lng)s %(lat)s)" % latlng) if (calls): error = "" for field in ("school", "train_station"): try: place = client.places_nearby(location=latlng, rank_by="distance", type=field)["results"][0] except IndexError: continue except Exception as e: error = e continue setattr(self, "nearest_%s" % field, place["name"]) place_latlng = place["geometry"]["location"] d = distance((latlng["lat"], latlng["lng"]), (place_latlng["lat"], place_latlng["lng"])).km setattr(self, "nearest_%s_distance" % field, round(d, 2)) if error: raise Exception(error)
def coordinate_encoder(address): gmaps = Client(key="XXXXXXXXXX") coordinates = gmaps.geocode(address)[0]['geometry']['location'] coords_lat = str(coordinates["lat"]) coords_lng = str(coordinates["lng"]) coords_total = coords_lat + "," + coords_lng return coords_total
def geocode_addresses(df, api_key): """Geocode addresses in a dataframe given that the dataframe has fields: - street - city - state - zip A 1 second pause is applied between requests to honor Google's usage limits. https://developers.google.com/maps/documentation/javascript/usage-and-billing#other-usage-limits """ gmaps = Client(key=api_key) for index, item in df.iterrows(): address = f'{item.street}, {item.city}, {item.state} {item.zip}' geocode_result = gmaps.geocode(address) sleep(1) if geocode_result: location = geocode_result[0]['geometry']['location'] formatted_address = geocode_result[0]['formatted_address'] df.at[index, 'formatted_address'] = formatted_address df.at[index, 'latitude'] = location['lat'] df.at[index, 'longitude'] = location['lng'] for info in geocode_result[0]['address_components']: key = info['types'][0] if key == 'administrative_area_level_2': df.at[index, 'county'] = info['long_name'] else: print('Failed to geocode:', index) return df
def geocode_addresses(df): """Geocode addresses in a dataframe.""" try: initialize_app() except ValueError: pass api_key = get_google_maps_api_key() gmaps = Client(key=api_key) for index, item in df.iterrows(): # FIXME: Handle existing lat and long more elegantly. # try: # if item.latitude and item.longitude: # continue # except: # pass address = f"{item.street}, {item.city}, {item.state} {item.zip}" geocode_result = gmaps.geocode(address) if geocode_result: df.at[index, "formatted_address"] = geocode_result[0]["formatted_address"] location = geocode_result[0]["geometry"]["location"] print(item.name, "-->", location) df.at[index, "latitude"] = location["lat"] df.at[index, "longitude"] = location["lng"] # TODO: Round latitude and longitude (4-6 decimal places?) for info in geocode_result[0]["address_components"]: key = info["types"][0] if key == "administrative_area_level_2": df.at[index, "county"] = info["long_name"] sleep(2) # Prevents spamming Google's servers (necessary?) return df
def main(): # Initialize the API object gmaps = Client(api_key_maps) route_map = Client(api_key_route) # origin = raw_input('Where are you starting? (please enter a valid address) ') # dest = raw_input('Where are you going? (please enter a valid address) ') origin = 'Ogunquit, ME' dest = 'Coral Gables, FL' lat0, lng0 = gmaps.geocode(origin)[0]['geometry']['location'].values() print 'start: ', lat0, lng0 lat1, lng1 = gmaps.geocode(dest)[0]['geometry']['location'].values() print 'end: ', lat1, lng1 routes = route_map.directions(origin, dest) lats = [] longs = [] times = [] for i, step in enumerate(routes[0]['legs'][0]['steps']): lats.append(step['start_location']['lat']) longs.append(step['start_location']['lng']) if i == len(routes[0]['legs'][0]['steps']) - 1: lats.append(step['end_location']['lat']) longs.append(step['end_location']['lng']) times.append(step['duration']['value']) new_times = [sum(times[:i]) for i in range(len(times) + 1)] travel_route = zip(lats, longs) markers = fifteen_mile_markers(zip(lats, longs)) # Dan - Test # print markers print[i[2] for i in segment_times(travel_route, new_times, markers)] gmap_plt = gmplot.GoogleMapPlotter((lat0 + lat1) / 2.0, (lng0 + lng1) / 2.0, 16) gmap_plt.plot([i[0] for i in markers], [i[0] for i in markers], 'r') gmap_plt.plot(lats, longs) gmap_plt.plot([mark[0] for mark in markers], [mark[1] for mark in markers]) gmap_plt.draw("mymap.html") return
def find_locales_inside(gmaps: googlemaps.Client, au_suburbs: pd.DataFrame, address: str): target = munchify(gmaps.geocode(address)[0]) bounds = target.geometry.bounds return au_suburbs.loc[(au_suburbs.lat >= bounds.southwest.lat) & (au_suburbs.lat <= bounds.northeast.lat) & (au_suburbs.lon >= bounds.southwest.lng) & (au_suburbs.lon <= bounds.northeast.lng)]
async def offer_park(ctx, *locations): location = "" for place in locations: location = location + place gmaps = Client('AIzaSyA0QJJKbsee6MVN7DAiVSeTUOV2F-V0rRs') latitude = gmaps.geocode(location)[0]['geometry']['location']['lat'] longitude = gmaps.geocode(location)[0]['geometry']['location']['lng'] results = findPlaces(latitude, longitude, "museum") MAX_RESULTS = 5 curr_result = 0 for result in results: if curr_result == MAX_RESULTS: return message = str(curr_result + 1) + ". Name: " + result[ 'name'] + "\n\tLocation: " + result['vicinity'] await ctx.send(message) curr_result = curr_result + 1
def check_googleMap(self, location): gmaps = Client(key='AIzaSyDAALCs0fN4bo9GdYeplrjdkpg6Lc8LpiU') #lat,lan = gmaps.address_to_latlng(location) ginfo = gmaps.geocode(location) dic = ginfo[0] lat = dic.get('geometry').get('bounds').get('northeast').get('lat') lng = dic.get('geometry').get('bounds').get('northeast').get('lng') return [lat,lng]
def getRouteFromUserToBusinessByAppointmentId(aid): api_key = "AIzaSyCeHf-jcEx21QPuV7BZOUOukikZ-bQYxDA" google = GoogleMaps(api_key) route = AppointmentsHandler().getRouteFromUserToBusinessByAppointmentId( aid) originaddress = route[0] + ', ' + route[1] destaddress = route[2] + ', ' + route[3] geocode_origin_result = google.geocode(originaddress) geocode_dest_result = google.geocode(destaddress) originlatitude = geocode_origin_result[0]['geometry']['location']['lat'] originlongitude = geocode_origin_result[0]['geometry']['location']['lng'] destlatitude = geocode_dest_result[0]['geometry']['location']['lat'] destlongitude = geocode_dest_result[0]['geometry']['location']['lng'] return render_template('route.html', originlongitude=originlongitude, originlatitude=originlatitude, destlongitude=destlongitude, destlatitude=destlatitude)
def getLocation(address_line1,address_line2,area,city,state,country,pincode): gmaps = GoogleMaps('AIzaSyBoy1plslvW_UTSM3JTWNLijJL1KjsKf60') address = str(address_line1)+ ',' + str(address_line2)+ ',' + str(area) + ',' + str(city) + ',' + str(state) + ',' + str(country) + ',' + str(pincode) geocode_result = gmaps.geocode(address) lat = geocode_result[0]['geometry']['location'] ['lat'] lon = geocode_result[0]['geometry']['location']['lng'] print(lat,lon) location = "SRID=4326;POINT ("+str(lat) + " " + str(lon)+")" print(location) return location
def getPlaceID(self, address_line1, address_line2, area, city, state, country, pincode): gmaps = GoogleMaps('AIzaSyBoy1plslvW_UTSM3JTWNLijJL1KjsKf60') address = str(address_line1) + ',' + str(address_line2) + ',' + str( area) + ',' + str(city) + ',' + str(state) + ',' + str( country) + ',' + str(pincode) geocode_result = gmaps.geocode(address) print(geocode_result[0]['formatted_address']) place_id = geocode_result[0]['place_id'] return place_id
def compress(address): try: gmaps = GoogleMaps('AIzaSyAH-SEZ1C_8Kb1ACyPCZZpZAJKKDuWD3Ro') geocode_result = gmaps.geocode(address) return geocode_result[0]['geometry']['location'][ 'lat'], geocode_result[0]['geometry']['location']['lng'] except IndexError: print("Address was wrong...") return "null", "null" except Exception as e: print("Unexpected error occurred.", e)
def post(self, request, *args, **kwargs): c = Client(key=request.event.settings.get('passbook_gmaps_api_key')) try: r = c.geocode(address=request.event.location, language=request.LANGUAGE_CODE.split("_")[0]) except ApiError: logger.exception('Google Maps API Error') return JsonResponse({ 'status': 'error', }) else: return JsonResponse({'status': 'ok', 'result': r})
class Gmaps: def __init__(self, APIKey): self.key = APIKey self.Gmaps = GoogleMaps(self.key) def get_Region(self, address): try: Location = self.Gmaps.geocode(address) region = Location[0]["address_components"][7]["short_name"] return region except: return ""
class location(metaclass=Singleton): def __init__(self, s=""): self.api_key = 'AIzaSyAhb_rBwht_tVUC0VEFMiQIqelRESZgL_c' if s != "": self.api_key = s self.gmaps = GoogleMaps(self.api_key) def find_location_for(self, adr): l = self.gmaps.geocode(adr) lat = l[0]["geometry"]["location"]["lat"] lon = l[0]["geometry"]["location"]["lng"] return lat, lon
def get_geopoints_byName(place): gmaps = Client(key='AIzaSyB7hXzGzrXUuQuPReZlERvxZO9YFakIzVw') geocode_result = gmaps.geocode(place) #print geocode_result if not geocode_result: return (0, 0) else: lat = geocode_result[0]['geometry']['location']['lat'] lon = geocode_result[0]['geometry']['location']['lng'] poi = geocode_result[0] return (lat, lon)
def main(): # Initialize the API object gmaps = Client(api_key_maps) route_map = Client(api_key_route) # origin = raw_input('Where are you starting? (please enter a valid address) ') # dest = raw_input('Where are you going? (please enter a valid address) ') # origin = '12 emery lane 07677' # dest = '431 riverside drive 10027' origin = 'New York City' dest = 'Miami' lat0, lng0 = gmaps.geocode(origin)[0]['geometry']['location'].values() print 'start: ', lat0, lng0 lat1, lng1 = gmaps.geocode(dest)[0]['geometry']['location'].values() print 'end: ', lat1, lng1 routes = route_map.directions(origin, dest) lats = [] longs = [] for i, step in enumerate(routes[0]['legs'][0]['steps']): lats.append(step['start_location']['lat']) longs.append(step['start_location']['lng']) lats.append(step['end_location']['lat']) longs.append(step['end_location']['lng']) travel_route = zip(lats, longs) markers = fifteen_mile_markers(travel_route) gmap_plt = gmplot.GoogleMapPlotter((lat0 + lat1) / 2.0, (lng0 + lng1) / 2.0, 16) # gmap_plt.plot(lats, longs) gmap_plt.scatter([mark[0] for mark in markers], [mark[1] for mark in markers], 'r', marker=True) gmap_plt.draw("mymap.html") return
def set_google_maps_fields(self, latlng=None): """ Uses the Google Maps API to set: - geocoded latlng """ client = Client(key=settings.GOOGLE_MAPS_API_SERVER_KEY) if not latlng: data = client.geocode(self.address) if not data: raise Exception("Unable to resolve the address: '%s'" % address) latlng = data[0]["geometry"]["location"] self.point = GEOSGeometry("POINT(%(lng)s %(lat)s)" % latlng)
def get_city_location(address, api_key=GOOGLE_API_KEY): """ Uses Google's API to convert location to latitude and longitude. Used in centering the map. :params address string: :returns location list: """ gmaps = Client(api_key) geocode = gmaps.geocode(address) location = list(geocode[0]['geometry']['location'].values()) return location
def get_geopoints_byName(): gmaps=Client(key='AIzaSyB7hXzGzrXUuQuPReZlERvxZO9YFakIzVw') place=raw_input('Enter the Place You want to search : ') geocode_result=gmaps.geocode(place) #print geocode_result if not geocode_result: print 'No results Found' else: lat=geocode_result[0]['geometry']['location']['lat'] lon=geocode_result[0]['geometry']['location']['lng'] poi=geocode_result[0] print lat print lon
def getCoord(location): start_time = time.time() msj = '' gmaps = GoogleMaps(os.getenv("GOOGLE_KEY")) wk = [] for key in location.keys(): if 'name' not in key: wk.append(key) address = normalizeWord(re.sub(',', '', ', '.join(value for value in dict(zip(wk, [location[k] for k in wk])).values() if value), 1)) print(f"ADDRESS: {address}") geocode_result = gmaps.geocode(address) data = {'long': {}, 'short': {}, 'location': {}} if geocode_result: for geolist in geocode_result: for item in geolist['address_components']: for category in item['types']: data['long'].update([(category, item['long_name'])]) data['short'].update([(category, item['short_name'])]) data['location'] = geolist['geometry']['location'] else: msj = 'Coordinates not found. Please check Address sent' try: data['long']['administrative_area_level_1'] = getLocal('provincias', [dict(nombre=data.get('long').get('administrative_area_level_1'))]).get('nombre', None) except IndexError: raise serializers.ValidationError('Could not validate Locality') # print('location country: {} - gmaps country: {}'.format(location['country'], data.get('long').get('country'))) # print('gmaps route: {}'.format(data.get('short').get('route'))) print(f"DATA: {data['long']['administrative_area_level_1']}") if data.get('long').get('country') == location['country'] and normalizeWord(data.get('long').get('administrative_area_level_1')) == normalizeWord(location['province']): if data.get('short').get('route'): location['street'] = data.get('short').get('route') if data.get('short').get('locality'): location['city'] = data.get('short').get('locality') location['province'] = data.get('long').get('administrative_area_level_1') location['latitude'] = data.get('location').get('lat') location['longitude'] = data.get('location').get('lng') else: msj = 'Address not Validated' print(data['long']['administrative_area_level_1']) print('--- Tiempo de ejecucion getCoord: {} segundos ---'.format((time.time() - start_time))) return location, msj return location, msj
def get_coordinates(address: str, api_key: str) -> tuple: """ Takes in a string address and Google API key. Returns a tuple with latitude and longitude. """ gmaps = GoogleMaps(api_key) geocode_result = gmaps.geocode(address) try: lat = geocode_result[0]['geometry']['location']['lat'] long = geocode_result[0]['geometry']['location']['lng'] return lat, long except IndexError: print(f'Error: coordinates not found for location: {address}') return 0, 0
def save(self, *args, **kwargs): # only update timestamp when the object is first created # when id is not set yet if not self.id: self.timestamp = timezone.now() self.updated = timezone.now() self.slug = slugify(self.title) gmaps = Client(key="AIzaSyDPPebmy_mg8ho15JXng1WD2ByUsYrT7bY") results = gmaps.geocode(address=self.address + ", " + self.city, region="CA") if results: self.lat = results[0]['geometry']['location']['lat'] self.lon = results[0]['geometry']['location']['lng'] return super(Post, self).save(*args, **kwargs)
def get_coord_dir(direction): load_dotenv() G_KEY = os.getenv("KEY_GOOGLE") gmaps = GoogleMaps(G_KEY) geocode_result = gmaps.geocode(direction) try: lat = geocode_result[0]["geometry"]["location"]["lat"] lon = geocode_result[0]["geometry"]["location"]["lng"] return lat, lon except: lat = None lon = None print('At least I tried')
def save(self, *args, **kwargs): # only update timestamp when the object is first created # when id is not set yet if not self.id: self.timestamp = timezone.now() self.updated = timezone.now() self.slug = slugify(self.title) gmaps = Client(key="AIzaSyDPPebmy_mg8ho15JXng1WD2ByUsYrT7bY") results = gmaps.geocode(address=self.address + ", " + self.city, region="CA") if results: self.lat = results[0]['geometry']['location']['lat'] self.lon = results[0]['geometry']['location']['lng'] return super(Post, self).save(*args, **kwargs)
def get_lat_lng(): """ For user input (eg. 'Constitution Ave NW & 10th St NW, Washington, DC', 'San Francisco, CA','Moscow, Russia')calculate geocode using Googlemaps API""" api_key = os.environ["GEOCODING_KEY"] gmaps = Client(api_key) address = request.args.get("address") for dictionary in gmaps.geocode(address): lat = dictionary["geometry"]["location"]["lat"] lng = dictionary["geometry"]["location"]["lng"] payload = {"lat": lat, "lon": lng} return payload
from googlemaps import Client as GoogleMaps from googlemaps import geocoding from googlemaps import convert API_Key="AIzaSyDVYcV4L2bOFuiEvjgvtTWsVieX7nZfzeo" gmaps = GoogleMaps(API_Key) address = raw_input("Enter a location: ") coordinates = gmaps.geocode(address) print coordinates
def getGeocode(location): c = Client("AIzaSyAGfQB9o_UWdN6NNn9L0jv_6ppXgW4W-uo") return c.geocode(location)[0]["geometry"]["location"]
# file.write(str(num) + ': ' + str(line.encode('utf-8').split('<')[2].split('>')[1]) + '\n') # num += 1 if "/streams/city" in line: city[0] = line.split("/streams/city/")[1].split("\"")[0] elif "/streams/state" in line: city[1] = line.split("/streams/state/")[1].split("\"")[0] elif "/streams/country" in line: city[2] = line.split("/streams/country/")[1].split("\"")[0] address = ", ".join(city) # print 'address',address.encode('utf-8') # file.write('address:'+str(address.encode('utf-8')) + '\n') # sys.exit() if not address == ", , ": # se l'indirizzo c'e' -> trova le coordinate geocoord = gmaps.geocode(address)[0]['geometry']['location'] lat = str(geocoord['lat']) lng = str(geocoord['lng']) record[2] = lat record[3] = lng if "/streams/tag" in line: record[4].append(line.split("/streams/tag/")[1].split("\"")[0]) tags = ", ".join(record[4]) # file.close() # get_data_stream(list_stream)
def from_place_to_lati_longi(place): gmaps = Client(API_KEY) address = place lat_lng = gmaps.geocode(address)[0][u'geometry'][u'location'] return lat_lng
def get_lat_long(self): gmaps = Client(key=settings.GMAPS_API_KEY) results = gmaps.geocode(address=self.address + ", " + self.city, region="CA") if results: lat_lng = results[0]['geometry']['location'] return lat_lng
def getgeo(address): gmaps = Client('AIzaSyA3i4VXAqU2qmSXKQ3ve4htc_QNxLaJpW4') json_response = gmaps.geocode(address) dictionary= json_response[0]['geometry']['location'] return dictionary[u'lat'],dictionary[u'lng']