DenisCarriere / geocoder

:earth_asia: Python Geocoder
http://geocoder.readthedocs.org
MIT License
1.62k stars 286 forks source link

Location by postal code with bing (details) does not work #426

Open caos21 opened 4 years ago

caos21 commented 4 years ago
import geocoder
g = geocoder.bing(location='Toronto, Ontario', postalCode='M1B', method='details') 
print(g.geojson)
print(g.latlng)

gives:

{'type': 'FeatureCollection', 'features': []}
None

I am proposing a fix in a PR #425, with this fix I got:

{'type': 'FeatureCollection', 'features': [{'type': 'Feature', 'properties': {'address': 'M1B, ON', 'bbox': [-79.25177764892578, 43.785438537597656, -79.13397216796875, 43.8382682800293], 'city': 'Toronto', 'confidence': 4, 'country': 'Canada', 'lat': 43.81153106689453, 'lng': -79.19551849365234, 'ok': True, 'postal': 'M1B', 'quality': 'Postcode2', 'raw': {'__type': 'Location:http://schemas.microsoft.com/search/local/ws/rest/v1', 'bbox': [43.785438537597656, -79.25177764892578, 43.8382682800293, -79.13397216796875], 'name': 'M1B, ON', 'point': {'type': 'Point', 'coordinates': [43.81153106689453, -79.19551849365234]}, 'address': {'adminDistrict': 'ON', 'adminDistrict2': 'Toronto', 'countryRegion': 'Canada', 'formattedAddress': 'M1B, ON', 'locality': 'Toronto', 'postalCode': 'M1B'}, 'confidence': 'Medium', 'entityType': 'Postcode2', 'geocodePoints': [{'type': 'Point', 'coordinates': [43.81153106689453, -79.19551849365234], 'calculationMethod': 'Rooftop', 'usageTypes': ['Display']}], 'matchCodes': ['UpHierarchy']}, 'state': 'ON', 'status': 'OK'}, 'bbox': [-79.25177764892578, 43.785438537597656, -79.13397216796875, 43.8382682800293], 'geometry': {'type': 'Point', 'coordinates': [-79.19551849365234, 43.81153106689453]}}]}
[43.81153106689453, -79.19551849365234]