googlemaps / google-maps-services-python Goto Github PK
View Code? Open in Web Editor NEWPython client library for Google Maps API Web Services
License: Apache License 2.0
Python client library for Google Maps API Web Services
License: Apache License 2.0
It'd be great to be able to look up elements or slices of the matrix response using syntax like this:
matrix = googlemaps.distance_matrix(["123 Happy St", "456 Sad St"], ["Westfield Bondi", "Top Ryde"])
matrix["Westfield Bondi"] # returns a list
matrix["123 Happy St", "Westfield Bondi"] # returns an element
Recommend clarifying in the documentation that even when units is specified as imperial, the returned value for distance is still measured in meters. This could result in a miscalculation. Example below:
u'rows': [{u'elements': [{u'distance': {u'text': u'149 mi', u'value': 240318}
Please anyone let me know how to use this availble codes.
I'm finidng it difficult to configure.
Thanks in advance... 👍
Hi guys,why i cannot access the place api after i enable bill account to my project? when i request the api,the server return such a error!
{
"error_message": "Google has disabled the use of APIs from this API project.",
"html_attributions": [ ],
"results": [ ],
"status": "REQUEST_DENIED"
}
gmaps = googlemaps.Client(client_id='id', client_secret='secret-No=',channel='channel')
TypeError: init() got an unexpected keyword argument 'channel'
Hello, I found that traffic_model="optimistic" sometimes takes longer than traffic_model="best guess". I don't know if this is because of the library or because of Google Maps, but I thought I'd ask, because it makes me question the results using "optimistic" more generally. That is, maybe the results using "optimistic" are not reliable in general.
The graph plots the travel time using the three traffic_model options, for all departure times on a particular day (in the future). Note how during the night the "optimisitic" is slower than the other two.
Also, here is code that generates this for a particular leaving time.
Code output:
['Travel time from: 12.979572,80.25271 to 12.921726,80.230478']
['Departure time (local): 16 Dec 2015 03:42:02']
['Time, no traffic, minutes: 12.566666666666666']
['Time in traffic, minutes: 9.45']
['Time in traffic (optimistic), minutes: 10.45']
Code:
__author__ = 'Gabriel Kreindler, [email protected]'
'''
This code shows that the traffic_model option sometimes generates counter-intuitive results.
The option traffic_model="optimistic" sometimes generates longer travel times compared to "best_guess" or "pessimistic".
(The latter is not shown here.)
'''
import googlemaps
import time
import calendar
# client
client = googlemaps.Client(key='KEY HERE')
# origin and destination
orig="12.979572,80.25271"
dest="12.921726,80.230478"
# query time
t1 = time.strptime("15 Dec 2015 22:12:02", "%d %b %Y %H:%M:%S")
nsec1 = calendar.timegm(t1)
# get offset
timezone_offset = client.timezone(orig, timestamp=nsec1)
timezone_offset_sec = timezone_offset['rawOffset']
# nice local time
t1_loc = time.gmtime(nsec1 + timezone_offset_sec) # local time
dep_time_local = time.strftime("%d %b %Y %H:%M:%S", t1_loc)
# get duration in traffic
dist = client.distance_matrix(orig, dest, departure_time=nsec1, mode="driving")
# parse
temp = dist["rows"][0]["elements"][0]
assert temp["status"]=="OK"
dist_output = temp["distance"]["value"]
dur_output = temp["duration"]["value"] # duration
dur_intraffic_output = temp["duration_in_traffic"]["value"]
# get duration in traffic
dist = client.distance_matrix(orig, dest, departure_time=nsec1, mode="driving", traffic_model="optimistic")
# parse
temp = dist["rows"][0]["elements"][0]
assert temp["status"]=="OK"
dur_intraffic_opt_output = temp["duration_in_traffic"]["value"]
print(['Travel time from: ' + orig + ' to ' + dest])
print(['Departure time (local): ' + dep_time_local])
print(['Time, no traffic, minutes: ' + str(dur_output/60)])
print(['Time in traffic, minutes: ' + str(dur_intraffic_output/60)])
print(['Time in traffic (optimistic), minutes: ' + str(dur_intraffic_opt_output/60)])
Hello sir.
How can i tracking realtime a device such as a phone?
Or any suggest.
Many thanks
I have been trying distance matrix function in googlemaps. it is working for many regions across world like London,New York, Hyderabad, Dublin etc but not working for Jeddah,Riyadh,Muscat,Cairo etc. For these regions i am getting JSON output as ZERO RESULT. What could be the problem and how to fix it?
Thanks
Anuj
/usr/lib/python2.6/site-packages/googlemaps/client.py(213)_get()->None
-> if self.sent_times and len(self.sent_times) == self.sent_times.maxlen:
(Pdb) r
AttributeError: "'collections.deque' object has no attribute 'maxlen'"
/usr/lib/python2.6/site-packages/googlemaps/places.py(87)places()
-> return client._get("/maps/api/place/textsearch/json", params)
it missed
It would be nice to allow several values for same component type.
Use case: You may want to filter sublocalities via locality component type ("locality matches against both locality and sublocality types") and in addition you may restrict result set by another locality.
Maybe we should extend converting components by defaultdict containing lists?
I am behind an authenticated proxy server any clues on how to supply the server and credentials?
The library keeps retrying requests that are rejected by the REST API with the following. I think this is not correct behavior. It masks what exactly is happening from the the python API developer and it does not matter how long you retry it will keep failing until the next day.
{u'status': u'OVER_QUERY_LIMIT', u'rows': [], u'error_message': u'You have exceeded your daily request quota for this API.', u'destination_addresses': [], u'origin_addresses': []}
Hey guys,
I swear i searched all issues and could not find an answer.
Is there a reason why requests<=2.6 requirement still hasn't changed?
Cheers
When Google Maps API responses with OVER_QUERY_LIMIT
status code, we should raise an exception instead of retrying. According to the API docs, OVER_QUERY_LIMIT
is an indicator that the user is out of quota. This quota is set on API manager and is on daily basis.
This is the relevant code from client.py
file:
def _get(self, url, params, first_request_time=None, retry_counter=0,
base_url=_DEFAULT_BASE_URL, accepts_clientid=True,
extract_body=None, requests_kwargs=None):
....
try:
if extract_body:
result = extract_body(resp)
else:
result = self._get_body(resp)
self.sent_times.append(time.time())
return result
except googlemaps.exceptions._RetriableRequest:
# Retry request.
return self._get(url, params, first_request_time, retry_counter + 1,
base_url, accepts_clientid, extract_body)
def _get_body(self, resp):
....
if api_status == "OVER_QUERY_LIMIT":
raise googlemaps.exceptions._RetriableRequest()
What is happening here is that when API responses with OVER_QUERY_LIMIT
, we repeat the request until we raise googlemaps.exceptions.Timeout
exception. This exception is misguiding as the real reason for failing in receiving the data is lack of quota not HTTP timeout.
I think we need to use one of the following solutions:
OVER_QUERY_LIMIT
we should just raise an appropriate exception straight away. No need to retrying.retry_counter
and eventually raise an appopriate exception.Please add support for requests-2.10.
Some packaging systems already use that version.
On the other hand, is this project dead? #107 still is unanswered.
I believe the proper usage is:
now = datetime.datetime.now()
--not--
now = datetime.now()
Hi,
Origin = 41.149516,-8.6102671
EndPoint = 41.149617,-8.610742
I'm using this for getting the directions from here 41.149516,-8.6102671 to 41.149617,-8.610742
Although this work fine on the website:
https://www.google.pt/maps/dir/41.149516,-8.6102671/41.149617,+-8.610742/@41.1495393,-8.6129531,17z/data=!3m1!4b1!4m6!4m5!1m0!1m3!2m2!1d-8.610742!2d41.149617
In the API returns the origin point instead of the endpoint since the distance between them is really close so my program gets stuck in an infinite loop.
I'm using the walking mode.
Regards
can this project be added to the anaconda distribution?
(Python 3.2.4) ImportError: No module named 'responses'
After I install it, I run the tests, but I see that error. How to solve this?
Hello.
I'm post request:
result = gmaps.places(message.text, location=(source_latitude,source_longitude), radius = 300, language = "ru')
But places in variable "result", more than 300m. I'm confused :(
Thank you.
When I ask for directions I get something like this:
[{u'distance': {u'text': u'2.6 km', u'value': 2592}, u'end_address': u'Piazza di Spagna, Piazza di Spagna, 00187 Roma', u'via_waypoint': [], u'start_address': u'Via Monte Zebio, 10, 00195 Roma, Italy', u'arrival_time': {u'text': u'4:48pm', u'time_zone': u'Europe/Rome', u'value': 1435934918}, u'steps': [{u'html_instructions': u'Walk to Lepanto', u'distance': {u'text': u'0.7 km', u'value': 746}, u'travel_mode': u'WALKING', u'start_location': {u'lat': 41.9173884, u'lng': 12.4644337}, u'polyline': {u'points': u'u~y~FumakAJFxDdCDMFMFMf@YZOb@EZPFHFJDHDJFPhCkAtBcAVMzAw@tAu@HEJGNILGBCDCFCdGuCCUd@?'}, u'duration': {u'text': u'9 mins', u'value': 554}, u'steps': [{u'html_instructions': u'Head <b>southwest</b> on <b>Via Monte Zebio</b> toward <b>Via Col di Lana</b>', u'distance': {u'text': u'0.1 km', u'value': 125}, u'travel_mode': u'WALKING', u'start_location': {u'lat': 41.9173884, u'lng': 12.4644337}, u'polyline': {u'points': u'u~y~FumakAJFxDdC'}, u'duration': {u'text': u'2 mins', u'value': 91}, u'end_location': {u'lat': 41.9163982, u'lng': 12.4637236}}, {u'html_instructions': u'At the roundabout, exit onto <b>Via Giuseppe Ferrari</b>', u'distance': {u'text': u'0.4 km', u'value': 424}, u'travel_mode': u'WALKING', u'maneuver': u'roundabout-right', u'start_location': {u'lat': 41.9163982, u'lng': 12.4637236}, u'polyline': {u'points': u'oxy~FgiakADMFMFMf@YZOb@EZPFHFJDHDJFPhCkAtBcAVMzAw@tAu@HEJG'}, u'duration': {u'text': u'5 mins', u'value': 319}, u'end_location': {u'lat': 41.9130456, u'lng': 12.4651835}}, {u'html_instructions': u'Continue onto <b>Via Lepanto</b>', u'distance': {u'text': u'0.2 km', u'value': 188}, u'travel_mode': u'WALKING', u'start_location': {u'lat': 41.9130456, u'lng': 12.4651835}, u'polyline': {u'points': u'qcy~FkrakANILGBCDCFCdGuC'}, u'duration': {u'text': u'2 mins', u'value': 137}, u'end_location': {u'lat': 41.9114969, u'lng': 12.4660814}}, {u'html_instructions': u'Turn <b>left</b> onto <b>Viale Giulio Cesare</b>', u'distance': {u'text': u'9 m', u'value': 9}, u'travel_mode': u'WALKING', u'maneuver': u'turn-left', u'start_location': {u'lat': 41.9114969, u'lng': 12.4660814}, u'polyline': {u'points': u'{yx~F_xakACUd@?'}, u'duration': {u'text': u'1 min', u'value': 7}, u'end_location': {u'lat': 41.9113299, u'lng': 12.4661938}}], u'end_location': {u'lat': 41.9113299, u'lng': 12.4661938}}, {u'html_instructions': u'Subway towards Anagnina', u'distance': {u'text': u'1.6 km', u'value': 1624}, u'travel_mode': u'TRANSIT', u'start_location': {u'lat': 41.9113299, u'lng': 12.4661938}, u'polyline': {u'points': u'yxx~FuxakAMDSsAwFwy@FqAFmA~@sCdHwH~G}HzHsILX'}, u'transit_details': {u'num_stops': 2, u'departure_stop': {u'location': {u'lat': 41.9113299, u'lng': 12.4661938}, u'name': u'Lepanto'}, u'headsign': u'Anagnina', u'arrival_time': {u'text': u'4:46pm', u'time_zone': u'Europe/Rome', u'value': 1435934779}, u'arrival_stop': {u'location': {u'lat': 41.9077813, u'lng': 12.4822433}, u'name': u'Spagna'}, u'line': {u'color': u'#ffffff', u'vehicle': {u'type': u'SUBWAY', u'local_icon': u'//maps.gstatic.com/mapfiles/transit/iw2/6/it-metro.png', u'name': u'Subway', u'icon': u'//maps.gstatic.com/mapfiles/transit/iw2/6/subway.png'}, u'agencies': [{u'url': u'http://www.agenziamobilita.roma.it/', u'phone': u'011 39 06 57003', u'name': u'Roma Servizi per la Mobilit\xe0 s.r.l.'}], u'short_name': u'MEA', u'text_color': u'#000000'}, u'departure_time': {u'text': u'4:42pm', u'time_zone': u'Europe/Rome', u'value': 1435934535}}, u'duration': {u'text': u'4 mins', u'value': 244}, u'end_location': {u'lat': 41.9077813, u'lng': 12.4822433}}, {u'html_instructions': u'Walk to Piazza di Spagna, Piazza di Spagna, 00187 Roma', u'distance': {u'text': u'0.2 km', u'value': 222}, u'travel_mode': u'WALKING', u'start_location': {u'lat': 41.9077813, u'lng': 12.4822433}, u'polyline': {u'points': u'sbx~F_}dkA\\]|@UlASB?B?B@@@@?@B`@xBrAk@LE^M'}, u'duration': {u'text': u'2 mins', u'value': 136}, u'steps': [{u'html_instructions': u'Head <b>south</b> on <b>Via di S. Sebastianello</b> toward <b>Piazza di Spagna</b>', u'distance': {u'text': u'0.1 km', u'value': 145}, u'travel_mode': u'WALKING', u'start_location': {u'lat': 41.9077813, u'lng': 12.4822433}, u'polyline': {u'points': u'sbx~F_}dkA\\]|@UlASB?B?B@@@@?@B`@xB'}, u'duration': {u'text': u'1 min', u'value': 82}, u'end_location': {u'lat': 41.9066712, u'lng': 12.4819486}}, {u'html_instructions': u'Turn <b>left</b> onto <b>Piazza di Spagna</b><div style="font-size:0.9em">Destination will be on the right</div>', u'distance': {u'text': u'77 m', u'value': 77}, u'travel_mode': u'WALKING', u'maneuver': u'turn-left', u'start_location': {u'lat': 41.9066712, u'lng': 12.4819486}, u'polyline': {u'points': u'u{w~Fe{dkArAk@LE^M'}, u'duration': {u'text': u'1 min', u'value': 54}, u'end_location': {u'lat': 41.9060235, u'lng': 12.4822688}}], u'end_location': {u'lat': 41.9060235, u'lng': 12.4822688}}], u'duration': {u'text': u'15 mins', u'value': 928}, u'end_location': {u'lat': 41.9060235, u'lng': 12.4822688}, u'start_location': {u'lat': 41.9173884, u'lng': 12.4644337}, u'departure_time': {u'text': u'4:33pm', u'time_zone': u'Europe/Rome', u'value': 1435933990}}]}]
Is there already a tool to convert it to a human readable format or I have to do it?
Can you guide me if this can be used with Proxies.
I realize this isn't a code issue per say, but it would be really nice if this worked on App Engine out of the box (no dependencies). Hey, while I'm at it, how about activation right within app.yaml's libraries section:
libraries:
- name: googlemaps
version: latest
Retrying a Client._get() with enterprise credentials (without a key) raises a ValueError in _generate_auth_url. It looks like this is due to a positional param issue in _get(), where accepts_clientid should be passed but extract_body is passed in its place.
Please let me know if you need a more specific test case, or if a pull request would help.
At the moment the last released version (2.4.2) is causing us to hold back our requests package version. Any chance of getting a new point release so we can bump requests?
Hi guys,i used Places python service to request data,but server always return data which is unicode format. how can i switch to utf8? thanks :)
here are my brief code:
gmaps = googlemaps.Client(key="my_key")
places_result = gmaps.places(name, location, radius)["results"]
print places_result
here are my result data:
[{u'rating': 4.7, u'name': u'Eiffel Tower', u'reference': u'CmRgAAAApTX1NmumYAMYE-tVzc-ZNIhArMBb_bnKHsVGlW_CyXvRtsZ_P7wvfFwcME2CDKlBCTLFAajTYzs08ZxPlLtMCEsNhXywzntz7c4fJHz0XQq08tTss3QpidkmQ0vy4JtuEhB1vw0uCZWm9K1yQNsx9phsGhQiAoJK0M2O-tjy703cxvsOCoufUQ', u'geometry': {u'location': {u'lat': 48.85837009999999, u'lng': 2.2944813}}, u'opening_hours': {u'weekday_text': [], u'open_now': False}, u'place_id': u'ChIJLU7jZClu5kcR4PcOOO6p3I0', u'formatted_address': u'Champ de Mars, 5 Avenue Anatole France, 75007 Paris, France', u'id': u'fd0cfb424bbd79bf28a832e1764f1c2aa5927714', u'types': [u'premise', u'point_of_interest', u'establishment'], u'icon': u'https://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png'}]
The Google Maps Reverse Geocoding service allows for the retrieval of a place's address details based on a place_id. The current implementation does not support this feature of the Geocoding service.
There are no methods builtin to over-ride the default query which is done based on lat/lng co-ordinates.
Currrently the only way to support this functionality of the Geocoding service is to refactor the existing code, with my local implementation being able to do do both, with a place_id receiving a higher priority if included in the args, else the default lat/lng lookup.
Was the excluion of queries by place_id, a conscious design decision.
I think this feature should have been included, considering Google's value outlook on place_id's vs any other metric for addressing place's in the Geocoding service.
File: googlemaps/geocoding.py:71
Hard to find relevant docs on the 'additional documentation' full google developers' site.
Direct link to python-specific docs would be better. I want to know simple things like a requirements list, e.g is this library compatible with python 2 and 3?
Currently working with the Elevations API, and I noticed that some of my bigger requests (single request, lots of points) returned with a HTTPError, status code 400. After checking the API docs and some testing, this seems to be an URL length issue: request URLs are limited to "about 2000 characters, after URL Encoding".
It seems that the googlemaps
module (or at least the Client
's elevation()
method does not perform a check on this URL length. My only option, currently, is to find the "sweet spot" in the number of points per request that will make sure the URL length stays below the limit, and use that number to split up my Elevation API requests.
Is auto-handling URL length something that could be built in?
The Java version has the ability for a user to set a QPS that matches their quota.
10 for free, or whatever a M4W customer has purchased.
new GeoApiContext().setQueryRateLimit(qps)
Request that a similar capability be introduced to the Python version.
I cant get consistent results, I mean json returned in one single language, when calling the geocode function without specifying the language kwargs.
As you can see below, once for a locality I got the region in French Région wallonne
and one in English Walloon Region
, the locality is in Fench and English whereas the country is in English both times
What is used as a default when nothing is specified ? I seems weird to me to have sometimes results in English, sometimes in French, but maybe I'm using it badly.
Thanks for pointers,
>>> from config import Config
>>> gmaps = googlemaps.Client(Config.GOOGLE_MAP_KEY, requests_kwargs=Config.PROXY)
>>> gmaps.geocode('Wanze, Belgium')
[{'address_components': [{'short_name': 'Wanze', 'long_name': 'Wanze', 'types': ['locality', 'political']}, {'short_name': 'LG', 'long_name': 'Liege'
'types': ['administrative_area_level_2', 'political']}, {'short_name': 'Walloon Region', 'long_name': 'Walloon Region', 'types': ['administrative_ar
a_level_1', 'political']}, {'short_name': 'BE', 'long_name': 'Belgium', 'types': ['country', 'political']}], 'geometry': {'location_type': 'APPROXIMA
E', 'location': {'lng': 5.2141303, 'lat': 50.5344663}, 'bounds': {'southwest': {'lng': 5.13206, 'lat': 50.50867}, 'northeast': {'lng': 5.26565, 'lat'
50.58255}}, 'viewport': {'southwest': {'lng': 5.13206, 'lat': 50.50867}, 'northeast': {'lng': 5.26565, 'lat': 50.58255}}}, 'formatted_address': 'Wan
e, Belgium', 'place_id': 'ChIJ4-WXdjeowUcRUHJNL6uZAAQ', 'types': ['locality', 'political']}, {'address_components': [{'short_name': 'Wanze', 'long_na
e': 'Wanze', 'types': ['political', 'sublocality', 'sublocality_level_1']}, {'short_name': 'Wanze', 'long_name': 'Wanze', 'types': ['locality', 'poli
ical']}, {'short_name': 'LG', 'long_name': 'Liège', 'types': ['administrative_area_level_2', 'political']}, {'short_name': 'Région wallonne', 'long_n
me': 'Région wallonne', 'types': ['administrative_area_level_1', 'political']}, {'short_name': 'BE', 'long_name': 'Belgium', 'types': ['country', 'po
itical']}, {'short_name': '4520', 'long_name': '4520', 'types': ['postal_code']}], 'geometry': {'location_type': 'APPROXIMATE', 'location': {'lng': 5
2141011, 'lat': 50.534476}, 'viewport': {'southwest': {'lng': 5.212752119708497, 'lat': 50.5331270197085}, 'northeast': {'lng': 5.215450080291502, 'l
t': 50.5358249802915}}}, 'formatted_address': 'Wanze, 4520 Wanze, Belgium', 'place_id': 'ChIJOaUhQ0uowUcRD_BJNFWv0gg', 'types': ['political', 'subloc
lity', 'sublocality_level_1']}]
>>> gmaps.geocode('Heusy, 4802 Verviers, Belgium')
[{'address_components': [{'short_name': 'Heusy', 'long_name': 'Heusy', 'types': ['political', 'sublocality', 'sublocality_level_1']}, {'short_name':
'Verviers', 'long_name': 'Verviers', 'types': ['locality', 'political']}, {'short_name': 'LG', 'long_name': 'Liège', 'types': ['administrative_area_l
evel_2', 'political']}, {'short_name': 'Région wallonne', 'long_name': 'Région wallonne', 'types': ['administrative_area_level_1', 'political']}, {'s
hort_name': 'BE', 'long_name': 'Belgium', 'types': ['country', 'political']}, {'short_name': '4802', 'long_name': '4802', 'types': ['postal_code']}],
'geometry': {'location_type': 'APPROXIMATE', 'location': {'lng': 5.866282099999999, 'lat': 50.57454449999999}, 'viewport': {'southwest': {'lng': 5.8
502747, 'lat': 50.5674578}, 'northeast': {'lng': 5.8822895, 'lat': 50.5816301}}}, 'formatted_address': 'Heusy, 4802 Verviers, Belgium', 'place_id': '
ChIJJyAs-dGLwEcRQj3XSgwdVH8', 'types': ['political', 'sublocality', 'sublocality_level_1']}]
now passing a language kwarg doesn't change the result for what is rendered in French
>>> gmaps.geocode('Heusy, 4802 Verviers, Belgium', language='en')
[{'address_components': [{'short_name': 'Heusy', 'long_name': 'Heusy', 'types': ['political', 'sublocality', 'sublocality_level_1']}, {'short_name':
'Verviers', 'long_name': 'Verviers', 'types': ['locality', 'political']}, {'short_name': 'LG', 'long_name': 'Liège', 'types': ['administrative_area_l
evel_2', 'political']}, {'short_name': 'Région wallonne', 'long_name': 'Région wallonne', 'types': ['administrative_area_level_1', 'political']}, {'s
hort_name': 'BE', 'long_name': 'Belgium', 'types': ['country', 'political']}, {'short_name': '4802', 'long_name': '4802', 'types': ['postal_code']}],
'geometry': {'location_type': 'APPROXIMATE', 'location': {'lng': 5.866282099999999, 'lat': 50.57454449999999}, 'viewport': {'southwest': {'lng': 5.8
502747, 'lat': 50.5674578}, 'northeast': {'lng': 5.8822895, 'lat': 50.5816301}}}, 'formatted_address': 'Heusy, 4802 Verviers, Belgium', 'place_id': '
ChIJJyAs-dGLwEcRQj3XSgwdVH8', 'types': ['political', 'sublocality', 'sublocality_level_1']}]
I'd love to differentiate between if a Directions API request with status "OK" or status "ZERO_RESULTS". But, the response
does not include this status field.
This status code is inspected in client.py
on line 239, but never stored in a response.
Can I find it somewhere else? Or is this something that could be considered to be added to the response, as returned by googlemaps.Client
?
Can you please add the traffic-model = "pessimistic", "optimistic" or "best-guess" (default) as a pass-through argument for Distance Matrix and Directions?
https://developers.google.com/maps/documentation/distance-matrix/intro#traffic-model
Code:
import googlemaps
from photobase import settings_base
gmaps = googlemaps.Client(key=settings_base.GOOGLE_MAPS_KEY)
# Geocoding an address
geocode_result = gmaps.geocode('1600 Amphitheatre Parkway, Mountain View, CA')
print(geocode_result)
Error:
/Users/olegbelousov/.virtualenvs/photo/bin/python /Users/olegbelousov/Library/Preferences/PyCharm50/scratches/scratch
Traceback (most recent call last):
File "/Users/olegbelousov/Library/Preferences/PyCharm50/scratches/scratch", line 7, in <module>
geocode_result = gmaps.geocode('1600 Amphitheatre Parkway, Mountain View, CA')
File "/Users/olegbelousov/.virtualenvs/photo/lib/python3.5/site-packages/googlemaps/geocoding.py", line 68, in geocode
return client._get("/maps/api/geocode/json", params)["results"]
File "/Users/olegbelousov/.virtualenvs/photo/lib/python3.5/site-packages/googlemaps/client.py", line 223, in _get
result = self._get_body(resp)
File "/Users/olegbelousov/.virtualenvs/photo/lib/python3.5/site-packages/googlemaps/client.py", line 246, in _get_body
body["error_message"])
googlemaps.exceptions.ApiError: REQUEST_DENIED (An internal error was found for this API project.)
EDIT:
All other addressed I've tested worked fine
The title pretty much says it. I had a small application I wanted to do for personal use. I would have preferred python since I know it, but I needed the Geometry API, so I also got to get my feet wet with javascript :-).
Traceback (most recent call last):
File "geo.py", line 46, in
geocode("API_KEY")
File "geo.py", line 44, in geocode
return client._get("/maps/api/geocode/json", params)["results"]
AttributeError: 'str' object has no attribute '_get'
Please can anyone resolve this error, I'm trying this from past 2 days but i'm not able to figure it out.
Hello,
The documentation states that you need to enable "Roads API" but it is not present under "Google Maps APIs" at https://console.developers.google.com. Is it renamed?
I tried the basic example code... but I'm stuck with this:
/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util/ssl_.py:79: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Traceback (most recent call last):
File "get_times.py", line 6, in <module>
geocode_result = gmaps.geocode('1600 Amphitheatre Parkway, Mountain View, CA')
File "/usr/local/lib/python2.7/dist-packages/googlemaps/geocoding.py", line 68, in geocode
return client._get("/maps/api/geocode/json", params)["results"]
File "/usr/local/lib/python2.7/dist-packages/googlemaps/client.py", line 205, in _get
raise googlemaps.exceptions.TransportError(e)
googlemaps.exceptions.TransportError: [Errno 1] _ssl.c:510: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
I can't see any way in the library API to point to the certificate. Where should I get this certificate and how to make the library see it?
client.py uses urllib.urlencode, which percent-encodes the tilde character (~) as %7E in order to generate the signature. ~ isn't really a reserved character, so this isn't guaranteed consistent with other URI libraries.
On the other hand, the base_url is encoded via requests in which the tilde issue has been corrected and no longer matches urllib's weird behavior.
Ultimately this results in a 403 error (client id omitted below):
"Unable to authenticate the request. Provided 'signature' is not valid for the provided client ID, or the provided 'client' is not valid.
The signature was checked against the URL: /maps/api/geocode/json?address=560+Maple+Street+South+%2310~&components=administrative_area%3AMN%7Clocality%3AWaconia%7Cpostal_code%3A55387&client=
If this does not match the URL you requested, please ensure that your request is URL encoded correctly. Learn more: https://developers.google.com/maps/documentation/business/webservices/auth"
Although tildes should be rare, ideal behavior would probably be either:
instead of waiting for a non-specific 403.
Thank you for making this wonderful package.
Is it possible to use the Chinese version from http://maps.google.cn ?
I searched the term "金波银波" at http://maps.google.cn and this result is more meaningful than https://www.google.com/maps
Searching Chinese targets is described by Google at:
https://developers.google.com/maps/documentation/javascript/basics
Thank you very much!
Hi,
Am I correct that by restricting the return value of the directions response to ["routes"], this new restricted response cannot be used to display the result back in a GoogleMaps canvas of a web page?
I know this can be done with direct call to the service in javascript, as demonstrated here: http://jsfiddle.net/user2314737/u9no8te4/ but I was wondering if I could do something similar using the Python library.
Thanks!
While the README says Python 2.7 or later, the setup file says Python 2.5 or later.
i.e.
def get_quickest(a, b):
return a["duration"] < b["duration"]
matrix.get_element(get_quickest) # returns the smallest element
And something similar for selecting entire columns / rows. I've not put much thought into how these selectors would work, so let's discuss options here.
I'm not sure if this is the proper place to post this, but when I try to connect to:
https://developers.google.com/console
Google loads forever and most likely returns a white webpage.
Is this still the place to ask for it? Is somebody else experimenting this issue also?
I got also problems at https://console.developers.google.com/
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.