googlemaps.exceptions.HTTPError: HTTP Error: 400
googlemaps.exceptions.HTTPError: HTTP Error: 400
我在 python
中有这段代码
from googlemaps import Client
apiKey = 'xxxx'
lat = input("Please enter latitude: ")
lng = input("Please enter longitude: ")
maps = Client(apiKey)
reverseGeo = maps.reverse_geocode(lat,lng)
address = reverseGeo['Placemark'][0]['address']
print(address)
每当我尝试 运行 并输入纬度和经度值时,就会发生此错误:
Please enter latitude: 5
Please enter longitude: 10
Traceback (most recent call last):
File "D:/Programs/github/mobile_application_development/Ex 1/part 1/main.py", line 6, in <module>
reverseGeo = maps.reverse_geocode(lat,lng)
File "C:\Users\Truong Dang\AppData\Roaming\Python\Python34\site-packages\googlemaps\client.py", line 356, in wrapper
result = func(*args, **kwargs)
File "C:\Users\Truong Dang\AppData\Roaming\Python\Python34\site-packages\googlemaps\geocoding.py", line 109, in reverse_geocode
return client._request("/maps/api/geocode/json", params)["results"]
File "C:\Users\Truong Dang\AppData\Roaming\Python\Python34\site-packages\googlemaps\client.py", line 253, in _request
result = self._get_body(response)
File "C:\Users\Truong Dang\AppData\Roaming\Python\Python34\site-packages\googlemaps\client.py", line 267, in _get_body
raise googlemaps.exceptions.HTTPError(response.status_code)
googlemaps.exceptions.HTTPError: HTTP Error: 400
请问原因和解决方法?
查看代码,我认为您需要以下列形式之一将 Latidude 经度作为单个参数传递:
- 列表
maps.reverse_geocode([lat, lng])
- 逗号分隔的字符串:
maps.reverse_geocode(lat + ',' + lng)
- 一个元组
maps.reverse_geocode((lat, lng))
基本上 reverse_geocode 的第一个参数被提供给 normalize_lat_lng,您可以在其中查看支持的表示形式
我在 python
中有这段代码from googlemaps import Client
apiKey = 'xxxx'
lat = input("Please enter latitude: ")
lng = input("Please enter longitude: ")
maps = Client(apiKey)
reverseGeo = maps.reverse_geocode(lat,lng)
address = reverseGeo['Placemark'][0]['address']
print(address)
每当我尝试 运行 并输入纬度和经度值时,就会发生此错误:
Please enter latitude: 5
Please enter longitude: 10
Traceback (most recent call last):
File "D:/Programs/github/mobile_application_development/Ex 1/part 1/main.py", line 6, in <module>
reverseGeo = maps.reverse_geocode(lat,lng)
File "C:\Users\Truong Dang\AppData\Roaming\Python\Python34\site-packages\googlemaps\client.py", line 356, in wrapper
result = func(*args, **kwargs)
File "C:\Users\Truong Dang\AppData\Roaming\Python\Python34\site-packages\googlemaps\geocoding.py", line 109, in reverse_geocode
return client._request("/maps/api/geocode/json", params)["results"]
File "C:\Users\Truong Dang\AppData\Roaming\Python\Python34\site-packages\googlemaps\client.py", line 253, in _request
result = self._get_body(response)
File "C:\Users\Truong Dang\AppData\Roaming\Python\Python34\site-packages\googlemaps\client.py", line 267, in _get_body
raise googlemaps.exceptions.HTTPError(response.status_code)
googlemaps.exceptions.HTTPError: HTTP Error: 400
请问原因和解决方法?
查看代码,我认为您需要以下列形式之一将 Latidude 经度作为单个参数传递:
- 列表
maps.reverse_geocode([lat, lng])
- 逗号分隔的字符串:
maps.reverse_geocode(lat + ',' + lng)
- 一个元组
maps.reverse_geocode((lat, lng))
基本上 reverse_geocode 的第一个参数被提供给 normalize_lat_lng,您可以在其中查看支持的表示形式