Azure 地图自动完成 - 仅限国家和城市
Azure maps autocomplete - country and city only
我正在编写一个自动完成服务,并且只想获得调用 Microsoft Azure 服务的国家和城市 - 没有地址和 POI 等。
我目前找到 Address Search where I would need to call https://atlas.microsoft.com/search/address,但它 returns 地址,而不是城市和国家 - 这会导致很多重复。
此外,如果我需要固定数量的自动完成选项(比如 15 个),则需要多次调用该服务,直到我拥有全部 15 个。最重要的是,我永远不知道是否有或没有输入的部分 country/city 组合有更多结果。
我不想使用固定列表,因为它需要维护。
如果可以使用 Azure,我暂时不想使用其他数据提供程序。
这还不受支持,但计划在未来支持。现在最接近的做法是使用 https://docs.microsoft.com/en-us/rest/api/maps/search/getsearchaddressstructured 服务,但它需要指定国家代码,因此您只能获得指定国家/地区的城市。例如,在以下查询中将 new
作为 municipality
传递:
https://atlas.microsoft.com/search/address/structured/json?api-version=1&municipality=new&countryCode=US&subscription-key=<Your_Key>
将return以下城市结果:
- 纽约
- 新奥尔良
- 新布朗费尔斯
- 新里奇港
- 新伯尔尼
- 纽黑文
- 新伊比利亚
- 纽卡斯尔
- 新贝德福德
- 新奥尔巴尼
这是原始回复
{
"summary": {
"query": "new",
"queryType": "NON_NEAR",
"queryTime": 23,
"numResults": 10,
"offset": 0,
"totalResults": 998,
"fuzzyLevel": 1
},
"results": [
{
"type": "Geography",
"id": "US/GEO/p0/1167",
"score": 2.6649377346,
"entityType": "Municipality",
"address": {
"municipality": "New York",
"countrySubdivision": "NY",
"countrySubdivisionName": "New York",
"countryCode": "US",
"country": "United States",
"countryCodeISO3": "USA",
"freeformAddress": "New York, NY"
},
"position": {
"lat": 40.71305,
"lon": -74.00723
},
"viewport": {
"topLeftPoint": {
"lat": 40.9175,
"lon": -74.25564
},
"btmRightPoint": {
"lat": 40.49587,
"lon": -73.70027
}
},
"boundingBox": {
"topLeftPoint": {
"lat": 40.9175,
"lon": -74.25564
},
"btmRightPoint": {
"lat": 40.49587,
"lon": -73.70027
}
},
"dataSources": {
"geometry": {
"id": "d49d86a4-0f4b-45f2-b607-31a84d02af00"
}
}
},
{
"type": "Geography",
"id": "US/GEO/p0/90711",
"score": 2.5113995075,
"entityType": "Municipality",
"address": {
"municipality": "New Orleans",
"countrySecondarySubdivision": "Orleans",
"countrySubdivision": "LA",
"countrySubdivisionName": "Louisiana",
"countryCode": "US",
"country": "United States",
"countryCodeISO3": "USA",
"freeformAddress": "New Orleans, LA"
},
"position": {
"lat": 29.95176,
"lon": -90.07462
},
"viewport": {
"topLeftPoint": {
"lat": 30.21747,
"lon": -90.24051
},
"btmRightPoint": {
"lat": 29.86582,
"lon": -89.62506
}
},
"boundingBox": {
"topLeftPoint": {
"lat": 30.21747,
"lon": -90.24051
},
"btmRightPoint": {
"lat": 29.86582,
"lon": -89.62506
}
},
"dataSources": {
"geometry": {
"id": "0000554c-4100-3c00-0000-0000596a7628"
}
}
},
{
"type": "Geography",
"id": "US/GEO/p0/103135",
"score": 2.4384012222,
"entityType": "Municipality",
"address": {
"municipality": "New Braunfels",
"countrySubdivision": "TX",
"countrySubdivisionName": "Texas",
"countryCode": "US",
"country": "United States",
"countryCodeISO3": "USA",
"freeformAddress": "New Braunfels, TX"
},
"position": {
"lat": 29.70988,
"lon": -98.11973
},
"viewport": {
"topLeftPoint": {
"lat": 29.91293,
"lon": -98.34627
},
"btmRightPoint": {
"lat": 29.59298,
"lon": -97.9908
}
},
"boundingBox": {
"topLeftPoint": {
"lat": 29.91293,
"lon": -98.34627
},
"btmRightPoint": {
"lat": 29.59298,
"lon": -97.9908
}
},
"dataSources": {
"geometry": {
"id": "9d7bf985-115b-423a-979a-97cc093c3166"
}
}
},
{
"type": "Geography",
"id": "US/GEO/p0/23041",
"score": 2.4345231056,
"entityType": "Municipality",
"address": {
"municipality": "New Port Richey",
"countrySecondarySubdivision": "Pasco",
"countrySubdivision": "FL",
"countrySubdivisionName": "Florida",
"countryCode": "US",
"country": "United States",
"countryCodeISO3": "USA",
"freeformAddress": "New Port Richey, FL"
},
"position": {
"lat": 28.2502,
"lon": -82.71408
},
"viewport": {
"topLeftPoint": {
"lat": 28.33939,
"lon": -82.76461
},
"btmRightPoint": {
"lat": 28.17319,
"lon": -82.57478
}
},
"boundingBox": {
"topLeftPoint": {
"lat": 28.33939,
"lon": -82.76461
},
"btmRightPoint": {
"lat": 28.17319,
"lon": -82.57478
}
},
"dataSources": {
"geometry": {
"id": "00005546-3300-3c00-0000-000059a7e5e6"
}
}
},
{
"type": "Geography",
"id": "US/GEO/p0/27115",
"score": 2.414732933,
"entityType": "Municipality",
"address": {
"municipality": "New Bern",
"countrySecondarySubdivision": "Craven",
"countrySubdivision": "NC",
"countrySubdivisionName": "North Carolina",
"countryCode": "US",
"country": "United States",
"countryCodeISO3": "USA",
"freeformAddress": "New Bern, NC"
},
"position": {
"lat": 35.10832,
"lon": -77.04612
},
"viewport": {
"topLeftPoint": {
"lat": 35.28085,
"lon": -77.26051
},
"btmRightPoint": {
"lat": 34.90304,
"lon": -76.83165
}
},
"boundingBox": {
"topLeftPoint": {
"lat": 35.28085,
"lon": -77.26051
},
"btmRightPoint": {
"lat": 34.90304,
"lon": -76.83165
}
},
"dataSources": {
"geometry": {
"id": "00004e43-3300-3c00-0000-0000596be1d9"
}
}
},
{
"type": "Geography",
"id": "US/GEO/p0/60622",
"score": 2.4027762413,
"entityType": "Municipality",
"address": {
"municipality": "New Haven",
"countrySecondarySubdivision": "New Haven",
"countrySubdivision": "CT",
"countrySubdivisionName": "Connecticut",
"countryCode": "US",
"country": "United States",
"countryCodeISO3": "USA",
"freeformAddress": "New Haven, CT"
},
"position": {
"lat": 41.30825,
"lon": -72.92416
},
"viewport": {
"topLeftPoint": {
"lat": 41.35038,
"lon": -72.99807
},
"btmRightPoint": {
"lat": 41.2464,
"lon": -72.81773
}
},
"boundingBox": {
"topLeftPoint": {
"lat": 41.35038,
"lon": -72.99807
},
"btmRightPoint": {
"lat": 41.2464,
"lon": -72.81773
}
},
"dataSources": {
"geometry": {
"id": "00005543-5400-3c00-0000-0000596911a2"
}
}
},
{
"type": "Geography",
"id": "US/GEO/p0/90802",
"score": 2.4020097256,
"entityType": "Municipality",
"address": {
"municipality": "New Iberia",
"countrySecondarySubdivision": "Iberia",
"countrySubdivision": "LA",
"countrySubdivisionName": "Louisiana",
"countryCode": "US",
"country": "United States",
"countryCodeISO3": "USA",
"freeformAddress": "New Iberia, LA"
},
"position": {
"lat": 30.00256,
"lon": -91.81698
},
"viewport": {
"topLeftPoint": {
"lat": 30.12129,
"lon": -91.9944
},
"btmRightPoint": {
"lat": 29.73782,
"lon": -91.65921
}
},
"boundingBox": {
"topLeftPoint": {
"lat": 30.12129,
"lon": -91.9944
},
"btmRightPoint": {
"lat": 29.73782,
"lon": -91.65921
}
},
"dataSources": {
"geometry": {
"id": "0000554c-4100-3c00-0000-00005968eae5"
}
}
},
{
"type": "Geography",
"id": "US/GEO/p0/61589",
"score": 2.3937933445,
"entityType": "Municipality",
"address": {
"municipality": "New Castle",
"countrySecondarySubdivision": "New Castle",
"countrySubdivision": "DE",
"countrySubdivisionName": "Delaware",
"countryCode": "US",
"country": "United States",
"countryCodeISO3": "USA",
"freeformAddress": "New Castle, DE"
},
"position": {
"lat": 39.66066,
"lon": -75.56184
},
"viewport": {
"topLeftPoint": {
"lat": 39.7245,
"lon": -75.66496
},
"btmRightPoint": {
"lat": 39.55219,
"lon": -75.50945
}
},
"boundingBox": {
"topLeftPoint": {
"lat": 39.7245,
"lon": -75.66496
},
"btmRightPoint": {
"lat": 39.55219,
"lon": -75.50945
}
},
"dataSources": {
"geometry": {
"id": "00005544-4500-3c00-0000-000059685073"
}
}
},
{
"type": "Geography",
"id": "US/GEO/p0/36482",
"score": 2.3928732872,
"entityType": "Municipality",
"address": {
"municipality": "New Bedford",
"countrySecondarySubdivision": "Bristol",
"countrySubdivision": "MA",
"countrySubdivisionName": "Massachusetts",
"countryCode": "US",
"country": "United States",
"countryCodeISO3": "USA",
"freeformAddress": "New Bedford, MA"
},
"position": {
"lat": 41.63405,
"lon": -70.92766
},
"viewport": {
"topLeftPoint": {
"lat": 41.74525,
"lon": -70.97843
},
"btmRightPoint": {
"lat": 41.58185,
"lon": -70.87872
}
},
"boundingBox": {
"topLeftPoint": {
"lat": 41.74525,
"lon": -70.97843
},
"btmRightPoint": {
"lat": 41.58185,
"lon": -70.87872
}
},
"dataSources": {
"geometry": {
"id": "0000554d-4100-3c00-0000-00005969fc6d"
}
}
},
{
"type": "Geography",
"id": "US/GEO/p0/12185",
"score": 2.3897461891,
"entityType": "Municipality",
"address": {
"municipality": "New Albany",
"countrySecondarySubdivision": "Floyd",
"countrySubdivision": "IN",
"countrySubdivisionName": "Indiana",
"countryCode": "US",
"country": "United States",
"countryCodeISO3": "USA",
"freeformAddress": "New Albany, IN"
},
"position": {
"lat": 38.28351,
"lon": -85.823
},
"viewport": {
"topLeftPoint": {
"lat": 38.40435,
"lon": -85.8853
},
"btmRightPoint": {
"lat": 38.22944,
"lon": -85.76089
}
},
"boundingBox": {
"topLeftPoint": {
"lat": 38.40435,
"lon": -85.8853
},
"btmRightPoint": {
"lat": 38.22944,
"lon": -85.76089
}
},
"dataSources": {
"geometry": {
"id": "00005549-4e00-3c00-0000-0000596b63cf"
}
}
}
]
}
我正在编写一个自动完成服务,并且只想获得调用 Microsoft Azure 服务的国家和城市 - 没有地址和 POI 等。
我目前找到 Address Search where I would need to call https://atlas.microsoft.com/search/address,但它 returns 地址,而不是城市和国家 - 这会导致很多重复。
此外,如果我需要固定数量的自动完成选项(比如 15 个),则需要多次调用该服务,直到我拥有全部 15 个。最重要的是,我永远不知道是否有或没有输入的部分 country/city 组合有更多结果。
我不想使用固定列表,因为它需要维护。
如果可以使用 Azure,我暂时不想使用其他数据提供程序。
这还不受支持,但计划在未来支持。现在最接近的做法是使用 https://docs.microsoft.com/en-us/rest/api/maps/search/getsearchaddressstructured 服务,但它需要指定国家代码,因此您只能获得指定国家/地区的城市。例如,在以下查询中将 new
作为 municipality
传递:
https://atlas.microsoft.com/search/address/structured/json?api-version=1&municipality=new&countryCode=US&subscription-key=<Your_Key>
将return以下城市结果:
- 纽约
- 新奥尔良
- 新布朗费尔斯
- 新里奇港
- 新伯尔尼
- 纽黑文
- 新伊比利亚
- 纽卡斯尔
- 新贝德福德
- 新奥尔巴尼
这是原始回复
{
"summary": {
"query": "new",
"queryType": "NON_NEAR",
"queryTime": 23,
"numResults": 10,
"offset": 0,
"totalResults": 998,
"fuzzyLevel": 1
},
"results": [
{
"type": "Geography",
"id": "US/GEO/p0/1167",
"score": 2.6649377346,
"entityType": "Municipality",
"address": {
"municipality": "New York",
"countrySubdivision": "NY",
"countrySubdivisionName": "New York",
"countryCode": "US",
"country": "United States",
"countryCodeISO3": "USA",
"freeformAddress": "New York, NY"
},
"position": {
"lat": 40.71305,
"lon": -74.00723
},
"viewport": {
"topLeftPoint": {
"lat": 40.9175,
"lon": -74.25564
},
"btmRightPoint": {
"lat": 40.49587,
"lon": -73.70027
}
},
"boundingBox": {
"topLeftPoint": {
"lat": 40.9175,
"lon": -74.25564
},
"btmRightPoint": {
"lat": 40.49587,
"lon": -73.70027
}
},
"dataSources": {
"geometry": {
"id": "d49d86a4-0f4b-45f2-b607-31a84d02af00"
}
}
},
{
"type": "Geography",
"id": "US/GEO/p0/90711",
"score": 2.5113995075,
"entityType": "Municipality",
"address": {
"municipality": "New Orleans",
"countrySecondarySubdivision": "Orleans",
"countrySubdivision": "LA",
"countrySubdivisionName": "Louisiana",
"countryCode": "US",
"country": "United States",
"countryCodeISO3": "USA",
"freeformAddress": "New Orleans, LA"
},
"position": {
"lat": 29.95176,
"lon": -90.07462
},
"viewport": {
"topLeftPoint": {
"lat": 30.21747,
"lon": -90.24051
},
"btmRightPoint": {
"lat": 29.86582,
"lon": -89.62506
}
},
"boundingBox": {
"topLeftPoint": {
"lat": 30.21747,
"lon": -90.24051
},
"btmRightPoint": {
"lat": 29.86582,
"lon": -89.62506
}
},
"dataSources": {
"geometry": {
"id": "0000554c-4100-3c00-0000-0000596a7628"
}
}
},
{
"type": "Geography",
"id": "US/GEO/p0/103135",
"score": 2.4384012222,
"entityType": "Municipality",
"address": {
"municipality": "New Braunfels",
"countrySubdivision": "TX",
"countrySubdivisionName": "Texas",
"countryCode": "US",
"country": "United States",
"countryCodeISO3": "USA",
"freeformAddress": "New Braunfels, TX"
},
"position": {
"lat": 29.70988,
"lon": -98.11973
},
"viewport": {
"topLeftPoint": {
"lat": 29.91293,
"lon": -98.34627
},
"btmRightPoint": {
"lat": 29.59298,
"lon": -97.9908
}
},
"boundingBox": {
"topLeftPoint": {
"lat": 29.91293,
"lon": -98.34627
},
"btmRightPoint": {
"lat": 29.59298,
"lon": -97.9908
}
},
"dataSources": {
"geometry": {
"id": "9d7bf985-115b-423a-979a-97cc093c3166"
}
}
},
{
"type": "Geography",
"id": "US/GEO/p0/23041",
"score": 2.4345231056,
"entityType": "Municipality",
"address": {
"municipality": "New Port Richey",
"countrySecondarySubdivision": "Pasco",
"countrySubdivision": "FL",
"countrySubdivisionName": "Florida",
"countryCode": "US",
"country": "United States",
"countryCodeISO3": "USA",
"freeformAddress": "New Port Richey, FL"
},
"position": {
"lat": 28.2502,
"lon": -82.71408
},
"viewport": {
"topLeftPoint": {
"lat": 28.33939,
"lon": -82.76461
},
"btmRightPoint": {
"lat": 28.17319,
"lon": -82.57478
}
},
"boundingBox": {
"topLeftPoint": {
"lat": 28.33939,
"lon": -82.76461
},
"btmRightPoint": {
"lat": 28.17319,
"lon": -82.57478
}
},
"dataSources": {
"geometry": {
"id": "00005546-3300-3c00-0000-000059a7e5e6"
}
}
},
{
"type": "Geography",
"id": "US/GEO/p0/27115",
"score": 2.414732933,
"entityType": "Municipality",
"address": {
"municipality": "New Bern",
"countrySecondarySubdivision": "Craven",
"countrySubdivision": "NC",
"countrySubdivisionName": "North Carolina",
"countryCode": "US",
"country": "United States",
"countryCodeISO3": "USA",
"freeformAddress": "New Bern, NC"
},
"position": {
"lat": 35.10832,
"lon": -77.04612
},
"viewport": {
"topLeftPoint": {
"lat": 35.28085,
"lon": -77.26051
},
"btmRightPoint": {
"lat": 34.90304,
"lon": -76.83165
}
},
"boundingBox": {
"topLeftPoint": {
"lat": 35.28085,
"lon": -77.26051
},
"btmRightPoint": {
"lat": 34.90304,
"lon": -76.83165
}
},
"dataSources": {
"geometry": {
"id": "00004e43-3300-3c00-0000-0000596be1d9"
}
}
},
{
"type": "Geography",
"id": "US/GEO/p0/60622",
"score": 2.4027762413,
"entityType": "Municipality",
"address": {
"municipality": "New Haven",
"countrySecondarySubdivision": "New Haven",
"countrySubdivision": "CT",
"countrySubdivisionName": "Connecticut",
"countryCode": "US",
"country": "United States",
"countryCodeISO3": "USA",
"freeformAddress": "New Haven, CT"
},
"position": {
"lat": 41.30825,
"lon": -72.92416
},
"viewport": {
"topLeftPoint": {
"lat": 41.35038,
"lon": -72.99807
},
"btmRightPoint": {
"lat": 41.2464,
"lon": -72.81773
}
},
"boundingBox": {
"topLeftPoint": {
"lat": 41.35038,
"lon": -72.99807
},
"btmRightPoint": {
"lat": 41.2464,
"lon": -72.81773
}
},
"dataSources": {
"geometry": {
"id": "00005543-5400-3c00-0000-0000596911a2"
}
}
},
{
"type": "Geography",
"id": "US/GEO/p0/90802",
"score": 2.4020097256,
"entityType": "Municipality",
"address": {
"municipality": "New Iberia",
"countrySecondarySubdivision": "Iberia",
"countrySubdivision": "LA",
"countrySubdivisionName": "Louisiana",
"countryCode": "US",
"country": "United States",
"countryCodeISO3": "USA",
"freeformAddress": "New Iberia, LA"
},
"position": {
"lat": 30.00256,
"lon": -91.81698
},
"viewport": {
"topLeftPoint": {
"lat": 30.12129,
"lon": -91.9944
},
"btmRightPoint": {
"lat": 29.73782,
"lon": -91.65921
}
},
"boundingBox": {
"topLeftPoint": {
"lat": 30.12129,
"lon": -91.9944
},
"btmRightPoint": {
"lat": 29.73782,
"lon": -91.65921
}
},
"dataSources": {
"geometry": {
"id": "0000554c-4100-3c00-0000-00005968eae5"
}
}
},
{
"type": "Geography",
"id": "US/GEO/p0/61589",
"score": 2.3937933445,
"entityType": "Municipality",
"address": {
"municipality": "New Castle",
"countrySecondarySubdivision": "New Castle",
"countrySubdivision": "DE",
"countrySubdivisionName": "Delaware",
"countryCode": "US",
"country": "United States",
"countryCodeISO3": "USA",
"freeformAddress": "New Castle, DE"
},
"position": {
"lat": 39.66066,
"lon": -75.56184
},
"viewport": {
"topLeftPoint": {
"lat": 39.7245,
"lon": -75.66496
},
"btmRightPoint": {
"lat": 39.55219,
"lon": -75.50945
}
},
"boundingBox": {
"topLeftPoint": {
"lat": 39.7245,
"lon": -75.66496
},
"btmRightPoint": {
"lat": 39.55219,
"lon": -75.50945
}
},
"dataSources": {
"geometry": {
"id": "00005544-4500-3c00-0000-000059685073"
}
}
},
{
"type": "Geography",
"id": "US/GEO/p0/36482",
"score": 2.3928732872,
"entityType": "Municipality",
"address": {
"municipality": "New Bedford",
"countrySecondarySubdivision": "Bristol",
"countrySubdivision": "MA",
"countrySubdivisionName": "Massachusetts",
"countryCode": "US",
"country": "United States",
"countryCodeISO3": "USA",
"freeformAddress": "New Bedford, MA"
},
"position": {
"lat": 41.63405,
"lon": -70.92766
},
"viewport": {
"topLeftPoint": {
"lat": 41.74525,
"lon": -70.97843
},
"btmRightPoint": {
"lat": 41.58185,
"lon": -70.87872
}
},
"boundingBox": {
"topLeftPoint": {
"lat": 41.74525,
"lon": -70.97843
},
"btmRightPoint": {
"lat": 41.58185,
"lon": -70.87872
}
},
"dataSources": {
"geometry": {
"id": "0000554d-4100-3c00-0000-00005969fc6d"
}
}
},
{
"type": "Geography",
"id": "US/GEO/p0/12185",
"score": 2.3897461891,
"entityType": "Municipality",
"address": {
"municipality": "New Albany",
"countrySecondarySubdivision": "Floyd",
"countrySubdivision": "IN",
"countrySubdivisionName": "Indiana",
"countryCode": "US",
"country": "United States",
"countryCodeISO3": "USA",
"freeformAddress": "New Albany, IN"
},
"position": {
"lat": 38.28351,
"lon": -85.823
},
"viewport": {
"topLeftPoint": {
"lat": 38.40435,
"lon": -85.8853
},
"btmRightPoint": {
"lat": 38.22944,
"lon": -85.76089
}
},
"boundingBox": {
"topLeftPoint": {
"lat": 38.40435,
"lon": -85.8853
},
"btmRightPoint": {
"lat": 38.22944,
"lon": -85.76089
}
},
"dataSources": {
"geometry": {
"id": "00005549-4e00-3c00-0000-0000596b63cf"
}
}
}
]
}