per*_*nce 4 google-maps bing-maps google-maps-api-3
是否可以使用 Google Maps API 或 Bing Maps API 获取街区?例如,是否可以获取“金融区”社区的值来搜索旧金山该社区的地址?如果没有,网上还有其他资源吗?谢谢!
address_components[]
是的,邻域作为地理编码 API 的一部分在数组中返回。
Google 有一个实时演示应用程序,展示了地理编码 API。该neighborhood
字段适用于出现在有社区的城市中的地点。
下面是一个使用Google 地图的 Python 客户端获取邻里数据的简单示例:
import googlemaps
API_KEY = "YOUR_API_KEY"
gmaps = googlemaps.Client(key=API_KEY)
print gmaps.geocode('3027 16th St, San Francisco, CA 94103, United States')
Run Code Online (Sandbox Code Playgroud)
这将打印以下内容:
[{'address_components': [{'long_name': '3027',
'short_name': '3027',
'types': ['street_number']},
{'long_name': '16th Street',
'short_name': '16th St',
'types': ['route']},
{'long_name': 'Mission District',
'short_name': 'Mission District',
'types': ['neighborhood', 'political']},
{'long_name': 'San Francisco',
'short_name': 'SF',
'types': ['locality', 'political']},
{'long_name': 'San Francisco County',
'short_name': 'San Francisco County',
'types': ['administrative_area_level_2',
'political']},
{'long_name': 'California',
'short_name': 'CA',
'types': ['administrative_area_level_1',
'political']},
{'long_name': 'United States',
'short_name': 'US',
'types': ['country', 'political']},
{'long_name': '94110',
'short_name': '94110',
'types': ['postal_code']},
{'long_name': '3402',
'short_name': '3402',
'types': ['postal_code_suffix']}],
'formatted_address': '3027 16th St, San Francisco, CA 94110, USA',
'geometry': {'bounds': {'northeast': {'lat': 37.764927, 'lng': -122.4201635},
'southwest': {'lat': 37.7646504,
'lng': -122.4203792}},
'location': {'lat': 37.7647804, 'lng': -122.4202906},
'location_type': 'ROOFTOP',
'viewport': {'northeast': {'lat': 37.7661376802915,
'lng': -122.4189223697085},
'southwest': {'lat': 37.76343971970851,
'lng': -122.4216203302915}}},
'place_id': 'ChIJxT0SpyN-j4ART07xF7G8NGE',
'types': ['premise']}]
Run Code Online (Sandbox Code Playgroud)
有关详细信息,请参阅官方地理编码 API 指南。