Search - Get Geocoding
用於獲取街道位址或地名的經緯度座標。
Get Geocoding API 是 HTTP GET 要求,會傳回所搜尋位置的經度和緯度座標。
在許多情況下,完整的搜尋服務可能太多,例如,如果您只對傳統地理編碼感興趣。 您也可以存取搜尋,以獨佔方式查閱位址。 地理編碼是藉由只叫用有問題的位址或部分位址來叫用地理編碼端點來執行。 地理編碼搜尋索引將會查詢街道層級數據上方的所有專案。 不會傳回任何景點(POIS)。 請注意,地理編碼器對錯字和不完整的位址非常寬容。 它還將處理來自確切街道位址或街道或十字路口以及更高層次的地理位置,如市中心、縣和州。 回應也會傳回詳細的位址屬性,例如街道、郵遞區號、市政和國家/地區資訊。
GET https://atlas.microsoft.com/geocode?api-version=2025-01-01
GET https://atlas.microsoft.com/geocode?api-version=2025-01-01&top={top}&query={query}&addressLine={addressLine}&countryRegion={countryRegion}&bbox={bbox}&view={view}&coordinates={coordinates}&adminDistrict={adminDistrict}&adminDistrict2={adminDistrict2}&adminDistrict3={adminDistrict3}&locality={locality}&postalCode={postalCode}
URI 參數
| 名稱 | 位於 | 必要 | 類型 | Description |
|---|---|---|---|---|
|
api-version
|
query | True |
string |
Azure 地圖服務 API 的版本號碼。 |
|
address
|
query |
string |
相對於該地區的位址的官方街道線,如當地或郵遞區編碼,屬性所指定。 此元素的一般用法是提供街道位址或任何官方位址。 當參數包含在請求中時 |
|
|
admin
|
query |
string |
地址的國家/地區細分部分,例如 WA。 當參數包含在請求中時 |
|
|
admin
|
query |
string |
結構化位址的縣,如國王。 當參數包含在請求中時 |
|
|
admin
|
query |
string |
結構化位址的具名區域。 當參數包含在請求中時 |
|
|
bbox
|
query |
number[] |
地球上的矩形區域,定義為周框方塊物件。 矩形的兩側是由經度和緯度值所定義。 當您指定此參數時,計算位置查詢的結果時,會考慮地理區域。 範例:lon1,lat1,lon2,lat2 |
|
|
coordinates
|
query |
number[] |
地球上指定為經度和緯度的點。 當您指定此參數時,會考慮使用者的位置,而且傳回的結果可能會與使用者更相關。 範例:&座標=lon,lat |
|
|
country
|
query |
string |
地理編碼結果的訊號 ISO 3166-1 Alpha-2 區域/國家/國家/地區代碼 指定,例如FR./ 當參數包含在請求中時 |
|
|
locality
|
query |
string |
地址的地區部分,例如西雅圖。 當參數包含在請求中時 |
|
|
postal
|
query |
string |
地址的郵遞區區編碼部分。 當參數包含在請求中時 |
|
|
query
|
query |
string |
包含位置相關信息的字串,例如位址或地標名稱。 |
|
|
top
|
query |
integer (int32) minimum: 1maximum: 20 |
將傳回的回應數目上限。 默認值:5,最小值:1,最大值:20。 |
|
|
view
|
query |
string |
字串,表示 ISO 3166-1 Alpha-2 區域/國家/國家/地區代碼。 這將改變地緣政治爭議邊界和標籤,以配合指定的用戶區域。 根據預設,即使您尚未在要求中定義 View 參數,仍會設定為 “Auto”。 如需詳細資訊,請參閱 支援的檢視,並查看可用的檢視。 |
要求標頭
| 名稱 | 必要 | 類型 | Description |
|---|---|---|---|
| Accept-Language |
string |
應該傳回搜尋結果的語言。 如需詳細資訊,請參閱 支援的語言。 |
|
| x-ms-client-id |
string |
指定要與 Azure AD 安全性模型搭配使用哪一個帳戶。 它代表 Azure 地圖服務帳戶的唯一標識碼,而且可以從 Azure 地圖服務管理平面帳戶 API 擷取。 如需在 Azure 地圖服務中使用 Microsoft Entra ID 安全性的詳細資訊,請參閱 在 Azure 地圖服務中管理驗證。 |
回應
| 名稱 | 類型 | Description |
|---|---|---|
| 200 OK |
還行 Media Types: "application/geo+json" 標題 x-ms-request-id: string |
|
| Other Status Codes |
發生未預期的錯誤。 Media Types: "application/geo+json" |
安全性
AADToken
這些是 Entra OAuth 2.0 流程
若要實作案例,建議您檢視
備註
- 此安全性定義 需要 使用
x-ms-client-id標頭來指出應用程式要求存取的 Azure 地圖服務資源。 這可以從 地圖管理 API取得。 -
Authorization URL專屬於 Azure 公用雲端實例。 主權雲端具有唯一的授權 URL,Microsoft Entra ID 設定。 - Azure 角色型訪問控制是從 azure 管理平面 設定, 透過 Azure 入口網站、PowerShell、CLI、Azure SDK 或 REST API。
- Azure 地圖服務 Web SDK 的使用,可讓您針對多個使用案例設定應用程式。
- 如需Microsoft身分識別平臺的詳細資訊,請參閱 Microsoft 身分識別平臺概觀。
類型:
oauth2
Flow:
implicit
授權 URL:
https://login.microsoftonline.com/common/oauth2/authorize
範圍
| 名稱 | Description |
|---|---|
| https://atlas.microsoft.com/.default | https://atlas.microsoft.com/.default |
subscription-key
這是透過 Azure 入口網站、PowerShell、CLI、Azure SDK 或 REST API,透過 Azure 管理平面建立 Azure 地圖服務 資源時所佈建的共用密鑰。
使用此金鑰時,任何應用程式都會獲得存取所有 REST API 的授權。 換句話說,這些目前可視為發行帳戶的主要密鑰。
對於公開的應用程式,我們建議使用可安全地儲存此密鑰的 Azure 地圖服務 REST API 伺服器對伺服器存取。
類型:
apiKey
位於:
header
SAS Token
這是透過 Azure 入口網站、PowerShell、CLI、Azure SDK 或 REST API,從 azure 地圖服務資源
使用此令牌時,任何應用程式都有權使用 Azure 角色型訪問控制進行存取,並更精細地控制特定令牌的到期、速率和區域。 換句話說,SAS 令牌可用來讓應用程式以比共用密鑰更安全的方式控制存取。
對於公開的應用程式,我們建議在 對應帳戶資源上設定允許的來源特定清單, 以限制轉譯濫用,並定期更新 SAS 令牌。
類型:
apiKey
位於:
header
範例
Search detail address 15127 NE 24th Street, Redmond, WA
範例要求
GET https://atlas.microsoft.com/geocode?api-version=2025-01-01&addressLine=15127 NE 24th Street&adminDistrict=WA&locality=Redmond
範例回覆
Content-Type: application/geo+json
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"address": {
"countryRegion": {
"name": "United States"
},
"adminDistricts": [
{
"shortName": "WA"
},
{
"shortName": "King County"
}
],
"formattedAddress": "15127 NE 24th St, Redmond, WA 98052",
"streetName": "NE 24th St",
"streetNumber": "15127",
"locality": "Redmond",
"postalCode": "98052",
"addressLine": "15127 NE 24th St"
},
"type": "Address",
"confidence": "High",
"matchCodes": [
"Good"
],
"geocodePoints": [
{
"geometry": {
"type": "Point",
"coordinates": [
-122.138681,
47.630358
]
},
"calculationMethod": "Rooftop",
"usageTypes": [
"Display"
]
},
{
"geometry": {
"type": "Point",
"coordinates": [
-122.1386787,
47.6302179
]
},
"calculationMethod": "Rooftop",
"usageTypes": [
"Route"
]
}
]
},
"geometry": {
"type": "Point",
"coordinates": [
-122.138681,
47.630358
]
},
"bbox": [
-122.14632282407,
47.626495282429325,
-122.13103917593001,
47.63422071757068
]
}
]
}
Search detail address 15127 NE 24th Street, Redmond, WA by addressLine
範例要求
GET https://atlas.microsoft.com/geocode?api-version=2025-01-01&addressLine=15127 NE 24th Street Redmond WA&countryRegion=US
範例回覆
Content-Type: application/geo+json
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"address": {
"countryRegion": {
"name": "United States"
},
"adminDistricts": [
{
"shortName": "WA"
},
{
"shortName": "King County"
}
],
"formattedAddress": "15127 NE 24th St, Redmond, WA 98052",
"streetName": "NE 24th St",
"streetNumber": "15127",
"locality": "Redmond",
"postalCode": "98052",
"addressLine": "15127 NE 24th St"
},
"type": "Address",
"confidence": "Medium",
"matchCodes": [
"Good"
],
"geocodePoints": [
{
"geometry": {
"type": "Point",
"coordinates": [
-122.138681,
47.630358
]
},
"calculationMethod": "Rooftop",
"usageTypes": [
"Display"
]
},
{
"geometry": {
"type": "Point",
"coordinates": [
-122.1386787,
47.6302179
]
},
"calculationMethod": "Rooftop",
"usageTypes": [
"Route"
]
}
]
},
"geometry": {
"type": "Point",
"coordinates": [
-122.138681,
47.630358
]
},
"bbox": [
-122.14632282407,
47.626495282429325,
-122.13103917593001,
47.63422071757068
]
}
]
}
Search detail address 15127 NE 24th Street, Redmond, WA by query
範例要求
GET https://atlas.microsoft.com/geocode?api-version=2025-01-01&query=15127 NE 24th Street Redmond WA
範例回覆
Content-Type: application/geo+json
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"address": {
"countryRegion": {
"name": "United States"
},
"adminDistricts": [
{
"shortName": "WA"
},
{
"shortName": "King County"
}
],
"formattedAddress": "15127 NE 24th St, Redmond, WA 98052",
"streetName": "NE 24th St",
"streetNumber": "15127",
"locality": "Redmond",
"postalCode": "98052",
"addressLine": "15127 NE 24th St"
},
"type": "Address",
"confidence": "High",
"matchCodes": [
"Good"
],
"geocodePoints": [
{
"geometry": {
"type": "Point",
"coordinates": [
-122.138681,
47.630358
]
},
"calculationMethod": "Rooftop",
"usageTypes": [
"Display"
]
},
{
"geometry": {
"type": "Point",
"coordinates": [
-122.1386787,
47.6302179
]
},
"calculationMethod": "Rooftop",
"usageTypes": [
"Route"
]
}
]
},
"geometry": {
"type": "Point",
"coordinates": [
-122.138681,
47.630358
]
},
"bbox": [
-122.14632282407,
47.626495282429325,
-122.13103917593001,
47.63422071757068
]
}
]
}
Search landmark Empire State Building by query
範例要求
GET https://atlas.microsoft.com/geocode?api-version=2025-01-01&query=empire state building
範例回覆
Content-Type: application/geo+json
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"address": {
"countryRegion": {
"name": "United States"
},
"adminDistricts": [
{
"shortName": "NY"
}
],
"formattedAddress": "Empire State Building, NY",
"locality": "New York"
},
"type": "PointOfInterest",
"confidence": "High",
"matchCodes": [
"Ambiguous"
],
"geocodePoints": [
{
"geometry": {
"type": "Point",
"coordinates": [
-73.98580932617188,
40.748435974121094
]
},
"calculationMethod": "Rooftop",
"usageTypes": [
"Display"
]
}
]
},
"geometry": {
"type": "Point",
"coordinates": [
-73.98580932617188,
40.748435974121094
]
},
"bbox": [
-73.98590850830078,
40.74833679199219,
-73.98571014404297,
40.74853515625
]
},
{
"type": "Feature",
"properties": {
"address": {
"countryRegion": {
"name": "United States"
},
"adminDistricts": [
{
"shortName": "NY"
},
{
"shortName": "New York County"
}
],
"formattedAddress": "Empire State Building, NY",
"locality": "Manhattan"
},
"type": "LandmarkBuilding",
"confidence": "High",
"matchCodes": [
"Ambiguous"
],
"geocodePoints": [
{
"geometry": {
"type": "Point",
"coordinates": [
-73.98500061035156,
40.74815368652344
]
},
"calculationMethod": "Rooftop",
"usageTypes": [
"Display"
]
}
]
},
"geometry": {
"type": "Point",
"coordinates": [
-73.98500061035156,
40.74815368652344
]
},
"bbox": [
-73.98710632324219,
40.747314453125,
-73.98412322998047,
40.74958038330078
]
}
]
}
定義
| 名稱 | Description |
|---|---|
| Address |
結果的位址 |
|
Admin |
地址的國家或地區中的細分名稱。 此元素通常被視為第一個命令系統管理細分,但在某些情況下,它也會包含國家/地區、相依性或區域的第二、第三或第四個順序細分。 |
|
Calculation |
用來計算地理編碼點的方法。 |
|
Confidence |
地理編碼位置結果的信賴等級相符。 搭配比對程式代碼使用此值,以判斷比對的更完整資訊。 地理編碼位置的信心是以許多因素為基礎,包括地理編碼位置和使用者位置的相對重要性。如果指定的話。 |
|
Country |
|
|
Error |
資源管理錯誤其他資訊。 |
|
Error |
錯誤詳細數據。 |
|
Error |
錯誤回應 |
|
Feature |
FeatureCollection 對象的類型必須是FeatureCollection。 |
|
Features |
|
|
Feature |
功能的類型必須是Feature。 |
|
Geocode |
地理編碼點的集合,其計算方式和建議的使用方式不同。 |
|
Geocoding |
從成功的地理編碼呼叫傳回此物件 |
|
Geo |
有效的 |
| Intersection |
結果的位址。 |
|
Match |
一或多個比對程式代碼值,代表回應中每個位置的地理編碼層級。 例如,具有 同樣地,具有 可能的值為:
|
| Properties | |
|
Usage |
地理編碼點的最佳使用。
每個地理編碼點都會定義為 |
Address
結果的位址
| 名稱 | 類型 | Description |
|---|---|---|
| addressLine |
string |
包含街道名稱和號碼的 AddressLine |
| adminDistricts |
地址的國家或地區中的細分名稱。 此元素通常被視為第一個命令系統管理細分,但在某些情況下,它也會包含國家/地區、相依性或區域的第二、第三或第四個順序細分。 |
|
| countryRegion | ||
| formattedAddress |
string |
格式化的 Address 屬性 |
| intersection |
結果的位址。 |
|
| locality |
string |
locality 屬性 |
| neighborhood |
string |
鄰里屬性 |
| postalCode |
string |
郵遞區號屬性 |
| streetName |
string |
formattedAddress 中的街道名稱 |
| streetNumber |
string |
街道上的號碼(如果可用),來自 formattedAddress |
AdminDistricts
地址的國家或地區中的細分名稱。 此元素通常被視為第一個命令系統管理細分,但在某些情況下,它也會包含國家/地區、相依性或區域的第二、第三或第四個順序細分。
| 名稱 | 類型 | Description |
|---|---|---|
| name |
string |
對應 adminDistrict 字段的名稱,若為 adminDistrict[0],這可能是州名的完整名稱,例如 Washington、For adminDistrict[1],這可能是該縣的完整名稱 |
| shortName |
string |
對應 adminDistrict 字段的簡短名稱,針對 adminDistrict[0],這可能是州名稱的簡短名稱,例如 WA,對於 adminDistrict[1],這可能是縣的簡短名稱 |
CalculationMethodEnum
用來計算地理編碼點的方法。
| 值 | Description |
|---|---|
| Interpolation |
使用插值將地理編碼點與道路上的點進行匹配。 |
| InterpolationOffset |
地理編碼點使用插值與道路上的點進行匹配,並使用額外的偏移量將點移動到街道一側。 |
| Parcel |
地理編碼點已與宗地中心匹配。 |
| Rooftop |
地理編碼點與建築物的屋頂匹配。 |
ConfidenceEnum
地理編碼位置結果的信賴等級相符。 搭配比對程式代碼使用此值,以判斷比對的更完整資訊。
地理編碼位置的信心是以許多因素為基礎,包括地理編碼位置和使用者位置的相對重要性。如果指定的話。
| 值 | Description |
|---|---|
| High |
如果置信度設置為 如果請求包含位置或視圖,則排名可能會相應更改。 例如,對“Paris”的位置查詢會可靠地 |
| Medium |
在某些情況下,返回的匹配項可能與請求中提供的資訊不在同一級別。 例如,請求可以指定地址資訊,而地理編碼服務可能只能匹配郵遞郵遞編碼。 在這種情況下,如果地理編碼服務具有郵遞區編碼與數據匹配的置信度,則置信度設置為, 如果查詢中的位置資訊不明確,並且沒有其他資訊來對位置進行排名(例如使用者位置或位置的相對重要性),則置信度設定為 如果查詢中的位置資訊未提供足夠的資訊來對特定位置進行地理編碼,則可能會傳回不太精確的位置值,並將置信度設定為 |
| Low |
CountryRegion
| 名稱 | 類型 | Description |
|---|---|---|
| ISO |
string |
國家/地區的 ISO |
| name |
string |
國家/地區名稱 |
ErrorAdditionalInfo
資源管理錯誤其他資訊。
| 名稱 | 類型 | Description |
|---|---|---|
| info |
object |
其他資訊。 |
| type |
string |
其他信息類型。 |
ErrorDetail
錯誤詳細數據。
| 名稱 | 類型 | Description |
|---|---|---|
| additionalInfo |
錯誤其他資訊。 |
|
| code |
string |
錯誤碼。 |
| details |
錯誤詳細數據。 |
|
| message |
string |
錯誤訊息。 |
| target |
string |
錯誤目標。 |
ErrorResponse
錯誤回應
| 名稱 | 類型 | Description |
|---|---|---|
| error |
error 物件。 |
FeatureCollectionEnum
FeatureCollection 對象的類型必須是FeatureCollection。
| 值 | Description |
|---|---|
| FeatureCollection |
FeaturesItem
| 名稱 | 類型 | Description |
|---|---|---|
| bbox |
number[] (double) |
周框方塊。 使用的投影 - EPSG:3857。 如需詳細資訊,請參閱 RFC 7946。 |
| geometry |
有效的 |
|
| id |
string |
傳回之功能的標識碼 |
| properties | ||
| type |
功能的類型必須是Feature。 |
FeatureTypeEnum
功能的類型必須是Feature。
| 值 | Description |
|---|---|
| Feature |
GeocodePoints
地理編碼點的集合,其計算方式和建議的使用方式不同。
| 名稱 | 類型 | Description |
|---|---|---|
| calculationMethod |
用來計算地理編碼點的方法。 |
|
| geometry |
有效的 |
|
| usageTypes |
地理編碼點的最佳使用。
每個地理編碼點都會定義為 |
GeocodingResponse
從成功的地理編碼呼叫傳回此物件
| 名稱 | 類型 | Description |
|---|---|---|
| features | ||
| nextLink |
string |
是傳回之功能下一頁的連結。 如果它是最後一頁,則沒有此欄位。 |
| type |
FeatureCollection 對象的類型必須是FeatureCollection。 |
GeoJsonPoint
有效的 GeoJSON Point 幾何類型。 如需詳細資訊,請參閱 RFC 7946。
| 名稱 | 類型 | Description |
|---|---|---|
| bbox |
number[] (double) |
周框方塊。 使用的投影 - EPSG:3857。 如需詳細資訊,請參閱 RFC 7946。 |
| coordinates |
number[] (double) |
|
| type |
string:
Point |
指定 |
Intersection
結果的位址。
| 名稱 | 類型 | Description |
|---|---|---|
| baseStreet |
string |
位置的主要街道。 |
| displayName |
string |
交集的完整名稱。 |
| intersectionType |
string |
交集的類型。 |
| secondaryStreet1 |
string |
第一條交集街道。 |
| secondaryStreet2 |
string |
如果有的話,第二個交集街道。 |
MatchCodesEnum
一或多個比對程式代碼值,代表回應中每個位置的地理編碼層級。
例如,具有 Good 和 Ambiguous 相符代碼的地理編碼位置表示找到多個地理位置資訊,而且地理編碼服務沒有搜尋上階層來尋找相符專案。
同樣地,具有 Ambiguous 和 UpHierarchy 相符碼的地理編碼位置表示找不到符合所有提供的位置資訊,因此地理編碼服務必須搜尋上階層,並在該層級找到多個相符專案。
Ambiguous 和 UpHierarchy 結果的範例是當您提供完整的地址資訊,但地理編碼服務找不到街址的相符專案,而是傳回多個 RoadBlock 值的資訊。
可能的值為:
Good:位置只有一個相符專案,或所有傳回的相符專案都會被視為強相符專案。 例如,紐約的查詢會傳回數個 Good 相符專案。
Ambiguous:位置是一組可能的相符專案。 例如,當您查詢街址 128 Main St.時,回應可能會傳回 128 北主街和 128 南主街的兩個位置,因為沒有足夠的資訊來判斷要選擇的選項。
UpHierarchy:位置代表向上移動地理階層。 當找不到位置要求的相符專案時,就會發生這種情況,因此會傳回較不精確的結果。 例如,如果找不到要求的位址相符專案,則可能會傳回具有 RoadBlock 實體類型的相符程式代碼 UpHierarchy。
| 值 | Description |
|---|---|
| Good | |
| Ambiguous | |
| UpHierarchy |
Properties
| 名稱 | 類型 | Description |
|---|---|---|
| address |
結果的位址 |
|
| confidence |
地理編碼位置結果的信賴等級相符。 搭配比對程式代碼使用此值,以判斷比對的更完整資訊。 地理編碼位置的信心是以許多因素為基礎,包括地理編碼位置和使用者位置的相對重要性。如果指定的話。 |
|
| geocodePoints |
地理編碼點的集合,其計算方式和建議的使用方式不同。 |
|
| matchCodes |
一或多個比對程式代碼值,代表回應中每個位置的地理編碼層級。 例如,具有 同樣地,具有 可能的值為:
|
|
| type |
string |
擇一:
|
UsageTypeEnum
地理編碼點的最佳使用。
每個地理編碼點都會定義為 Route 點、Display 點或兩者。
如果您要建立通往位置的路由,請使用 Route 點。 如果您要在地圖上顯示位置,請使用 Display 點。 例如,如果位置是公園,Route 點可能會指定可以用汽車進入的公園入口,而 Display 點可能是指定公園中心點。
| 值 | Description |
|---|---|
| Display | |
| Route |