使用Google Maps API或Bing Maps API是否可以获取邻域?例如,是否可以在旧金山“金融区”搜索地址并获取该邻域的价值?如果不行,是否有其他在线资源可用?谢谢!
使用Google Maps API或Bing Maps API是否可以获取邻域?例如,是否可以在旧金山“金融区”搜索地址并获取该邻域的价值?如果不行,是否有其他在线资源可用?谢谢!
是的,在 Geocoding API 的 address_components[]
数组中,会返回地理编码结果中的邻居区信息。
Google 有一个演示应用展示了 Geocoding API 的使用,在线演示。当所查询城市有邻居区时,该字段在可用。
以下是使用 Python 的 Google Maps 客户端 获取邻居区数据的简单示例:
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')
[{'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']}]
请查看官方Geocoding API指南以获取更多信息。
var componentForm = {
...,
neighborhood: 'short_name',
...,
};
标签
。 <tr>
<td class="label">Neighbourhood</td>
<td class="wideField" colspan="3"><input class="field"
id="neighborhood" disabled="true"></input></td>
</tr>
Google Places API 可以让您获取社区信息。 但是从 API 获取的信息必须用于 Google 地图。