Assigned
Status Update
Comments
ca...@google.com <ca...@google.com> #2
This is a good idea and definitely worth investigating.
I think there's something to be said about what scope these coroutines would run in, but it should be possible to pass it back from adapter internally.
Description
#REMINDER: Please do not disclose any possible PII such as: email address, IP, contact number, any part of name, project numbers and billing accounts as these information may violate security and privacy. Comments or attachments that include PII will be removed and restricted from public viewing.
Furthermore, please refrain from replying to a comment as this will make your email address visible. Instead, you may use the Issue Tracker’s comment feature for your replies.
It is OK to share your API Project ID, but _not_ API keys or client ID credentials.
To learn more about personal data, visit
===========================================================================================
Feature Request
-----------------------
What would you like to see us add to this API?
I am trying to locate Restaurants within 1 mile of these co-ordinates 40.76005, -73.97244 and I am getting list of all restaurants nearby except for this "Near E 54th St by Cellini Italian Restaurant and Bar in Midtown Manhattan". I can see this place in google map but the Python code that I wrote isn't picking this location.
My project id is My Project Google API.
Please suggest if I need to update the code or there is any bug in the Places API
These are the list of restaurants I am seeing after running Python code which doesn't include Cellini Italian Restaurant and Bar in Midtown Manhattan.
- Name: Madison Restaurant, Address: 965 1st Ave., New York, NY 10022, USA
- Name: The Bar Downstairs and Kitchen, Address: 485 5th Ave, New York, NY 10017, USA
- Name: Duomo51, Address: 25 W 51st St 7th floor, New York, NY 10019, USA
- Name: Tartinery Café - Bar | Grand Central, Address: Grand Central Station, Lower Level Dining Concourse, 89 E 42nd St, New York, NY 10017, USA
- Name: 6B RESTAURANT, Address: 60 E 42nd St, New York, NY 10165, USA
- Name: Ty Bar, Address: 57 E 57th St, New York, NY 10022, USA
- Name: Silver Star Restaurant, Address: 1238 2nd Ave, New York, NY 10065, USA
- Name: Club Bar & Grill, Address: 4 Pennsylvania Plaza, New York, NY 10001, USA
- Name: Villard, Address: 455 Madison Avenue at, E 50th St, New York, NY 10022, USA
- Name: Connolly's, Address: 121 W 45th St, New York, NY 10036, USA
- Name: Bill's Bar & Burger, Address: 16 W 51st St, New York, NY 10019, USA
- Name: Guantanamera, Address: 939 8th Ave, New York, NY 10019, USA
- Name: Monkey Bar, Address: 60 E 54th St, New York, NY 10022, USA
- Name: Rosie Dunn's Victorian Pub, Address: 729 3rd Ave, New York, NY 10017, USA
- Name: Trademark Bar + Kitchen, Address: 38 W 36th St., New York, NY 10018, USA
- Name: Socarrat Paella Bar - Midtown East, Address: 953 2nd Ave, New York, NY 10022, USA
- Name: The Naked Pig, Address: 922 3rd Ave, New York, NY 10022, USA
- Name: Obicà Mozzarella, Address: 590 Madison Ave, New York, NY 10022, USA
- Name: Porter House Bar and Grill, Address: 10 Columbus Cir, New York, NY 10019, USA
- Name: The Polo Bar, Address: 1 E 55th St, New York, NY 10022, USA
Issue report
----------------
What steps will reproduce the problem? Please provide a link to a
demonstration page if at all possible, or attach code.
Python code
-------------------------------------------
import googlemaps
import re
def find_nearby_locations(latitude, longitude, api_key, radius=1000):
"""
Finds nearby locations of various types using the Google Places API,
returns both name and address, and filters out results not in the USA.
Args:
latitude (float): The latitude of the center point.
longitude (float): The longitude of the center point.
api_key (str): Your Google Maps API key.
radius (int): The search radius in meters.
Returns:
dict: A dictionary of location names and addresses (only in USA) for each category.
"""
gmaps = googlemaps.Client(key=api_key)
location_details = {
'School': [],
'Highway': [],
'Restaurant & Bar': [],
'Bus Stop': [],
'Store': [],
'ATM': [],
'University': []
}
place_types = {
'School':'school',
'Restaurant & Bar': ['restaurant','bar'],
'Bus Stop': 'bus_station',
'Highway': 'highway',
'Store':'store',
'ATM':'atm',
'University': 'university'
}
for cat, place_type in place_types.items():
if isinstance(place_type, list):
places_result = gmaps.places(query="|".join(place_type), location=(latitude, longitude), radius=radius)
else:
places_result = gmaps.places(query=place_type, location=(latitude, longitude), radius=radius)
if 'results' in places_result:
for place in places_result['results']:
place_id = place.get('place_id')
if place_id:
place_details=gmaps.place(place_id=place_id)
if place_details and place_details.get('result'):
address = place_details['result'].get('formatted_address')
name = place_details['result'].get('name')
# Check if the address is in the USA
if address and ", USA" in address or re.search(r',\s*USA$', address):
location_details[cat].append({
'name': name,
'address': address
})
return location_details
if __name__ == '__main__':
api_key = 'AIzaSyDnxflT3qDGc6ETsJCWy0F_Emvq7B_hv8U' # Replace with your actual API key
latitude = 40.76005
longitude = -73.97244
nearby_locations = find_nearby_locations(latitude, longitude, api_key)
for category, locations in nearby_locations.items():
print(f"\n{category}:\n")
for loc in locations:
print(f"- Name: {loc['name']}, Address: {loc['address']}")