地理编码返回错误 lat/long

Geocode returning wrong lat/long

我正在使用此代码对该地址进行地理编码以获取纬度和经度,但它返回了错误的坐标。

import requests
address = '50 Bega St, Tathra NSW 2550, Australia'
response = requests.get('https://maps.googleapis.com/maps/api/geocode/json?address= address &key= ****')

resp_json_payload = response.json()

print(resp_json_payload)
print(resp_json_payload['results'][0]['geometry']['location'])

预期结果:-36.730478 149.985058

实际结果:'lat':37.09024,'lng':-95.712891

Code compiled on Python 3.6, you might want to use a different url parsing library for older version of Python.

import requests
import urllib.parse
address = '50 Bega St, Tathra NSW 2550, Australia'
api_key = 'your_api_key'
encoded_address = urllib.parse.quote(address)
response = requests.get('https://maps.googleapis.com/maps/api/geocode/json?address='+encoded_address+'&key='+api_key)

resp_json_payload = response.json()

print(resp_json_payload)
print(resp_json_payload['results'][0]['geometry']['location'])

希望对您有所帮助。