Search - Get Geocoding
用於獲取街道地址或地名的經緯度坐標。
API Get Geocoding 是一個 HTTP GET 請求,它傳回正在搜尋的位置的經度和緯度座標。
在許多情況下,完整的搜尋服務可能太多,例如,如果您只對傳統地理編碼感興趣。 您也可以存取搜尋,以獨佔方式查閱位址。 地理編碼是透過僅使用相關地址或部分地址點擊地理編碼端點來執行的。 地理編碼搜尋索引將會查詢街道層級數據上方的所有專案。 不會傳回任何興趣點 (POI)。 請注意,地理編碼器對錯字和不完整的位址非常寬容。 它還將處理從確切的街道地址或街道或十字路口以及更高級別的地理區域(例如市中心、縣和州)的所有內容。 回應也會傳回詳細的地址屬性,例如街道、郵遞區號、市政當局和國家/地區資訊。
GET {endpoint}/geocode?api-version=2026-01-01
GET {endpoint}/geocode?api-version=2026-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 |
|---|---|---|---|---|
|
endpoint
|
path | True |
string |
|
|
api-version
|
query | True |
string minLength: 1 |
用於此作業的 API 版本。 |
|
address
|
query |
string |
地址相對於區域的官方街道線,由當地或郵遞區號屬性指定。 此元素的典型用途是提供街道地址或任何官方地址。 當參數包含在請求中時 |
|
|
admin
|
query |
string |
地址的國家/地區細分部分,例如 WA。 當參數包含在請求中時 |
|
|
admin
|
query |
string |
結構化地址的縣,例如 King。 當參數包含在請求中時 |
|
|
admin
|
query |
string |
結構化位址的具名區域。 當參數包含在請求中時 |
|
|
bbox
|
query |
number[] |
地球上的矩形區域,定義為周框方塊物件。 矩形的邊由經度和緯度值定義。 若指定此參數,計算位置查詢的結果時將會考量地理區域。 範例:lon1,lat1,lon2,lat2。 最小尺寸:約 0.00001 度(~0.01 公尺)。 最大大小:最多全域範圍 (-180,-90 到 180,90) |
|
|
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 區域/國碼 (地區碼)。 這將改變地緣政治爭議邊界和標籤,以配合指定的用戶區域。 根據預設,「檢視」參數會設定為「自動」,即使您未在要求中定義亦是如此。 如需詳細資訊,請參閱 支援的檢視,並查看可用的檢視。 |
要求標頭
| 名稱 | 必要 | 類型 | Description |
|---|---|---|---|
| Accept-Language |
string |
應該傳回搜尋結果的語言。 如需詳細資訊,請參閱 支援的語言。 |
|
| x-ms-client-id |
string |
指定哪個帳號是打算搭配 Azure AD 安全模型一起使用。 它代表 Azure 地圖服務 帳號的唯一 ID,並可從 Azure 地圖服務 管理平面帳號 API 取得。 欲了解更多在Azure 地圖服務中使用Microsoft Entra ID安全,請參見管理 Azure 地圖服務 認證。 |
回應
| 名稱 | 類型 | Description |
|---|---|---|
| 200 OK |
要求已成功。 Media Types: "application/geo+json", "application/json" |
|
| Other Status Codes |
未預期的錯誤回應。 Media Types: "application/geo+json", "application/json" 標題 x-ms-error-code: string |
安全性
AadToken
這些是Microsoft Entra OAuth 2.0流。 當與 Azure 基於角色的存取 控制結合時,可以用來控制對 Azure 地圖服務 REST API 的存取。 Azure 角色基礎存取控制用於指定對一個或多個 Azure 地圖服務 資源帳號或子資源的存取權限。 任何使用者、群組或服務主體皆可透過內建角色或由一個或多個 REST API 權限組成的自訂角色獲得存取權限,Azure 地圖服務\n\n實作情境時,建議檢視 authentication concepts。 總結來說,此安全定義提供了透過能對特定 API 與範圍進行存取控制的物件來建模應用程式的解決方案。\n\n#### 註解\n* 此安全定義要求使用 x-ms-client-id標頭來指示應用程式請求存取的Azure 地圖服務資源。 此功能可從 Maps 管理 API 取得。\n* \nAuthorization URL 是針對Azure公有雲實例的專用。 主權雲擁有獨特的授權網址和 Microsoft Entra ID 設定。 \n* \nAzure 基於角色的存取控制由
類型:
oauth2
Flow:
implicit
授權 URL:
https://login.microsoftonline.com/common/oauth2/authorize
範圍
| 名稱 | Description |
|---|---|
| https://atlas.microsoft.com/.default |
subscription-key
這是一個共享金鑰,當你在Azure入口網站建立Azure 地圖服務帳號,或使用 PowerShell、CLI、Azure SDK 或 REST API 時,會被配置。\n\n 有了這個金鑰,任何應用程式都能存取所有 REST API。 換句話說,這個金鑰可以作為發行帳戶的主金鑰使用。\n\n 對於公開的應用程式,我們建議使用 機密客戶端應用程式方法來存取Azure 地圖服務 REST API,以便您的金鑰能安全儲存。
類型:
apiKey
位於:
header
SAS Token
這是一個共享存取簽章憑證,透過 List SAS 操作在 Azure 地圖服務資源,經由 Azure 管理層面,透過 Azure 入口網站、PowerShell、CLI、Azure SDK 或 REST API 建立。\n\n 使用此憑證,任何應用程式都被授權使用 Azure 存取基於角色的存取控制,以及對特定代幣的到期日、速率及使用區域的細緻控制。 換句話說,SAS 令牌可以用來讓應用程式以比共享金鑰更安全的方式控制存取。\n\n 對於公開暴露的應用程式,我們建議在 Map 帳號資源 上設定特定的允許來源清單,以減少渲染濫用,並定期更新 SAS 令牌。
類型:
apiKey
位於:
header
範例
Search detail address 15127 NE 24th Street, Redmond, WA
範例要求
GET {endpoint}/geocode?api-version=2026-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 {endpoint}/geocode?api-version=2026-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 {endpoint}/geocode?api-version=2026-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 {endpoint}/geocode?api-version=2026-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 |
結果的位址 |
|
Address |
地址的國家或地區中的細分名稱。 |
|
Address |
國家或地區及其名稱和 ISO 代碼。 |
|
Azure. |
error 物件。 |
|
Azure. |
包含錯誤詳細數據的回應。 |
|
Azure. |
物件,包含有關錯誤的更特定資訊。 根據 Azure REST API 指引 - https://aka.ms/AzureRestApiGuidelines#handling-errors。 |
|
Calculation |
用來計算地理編碼點的方法。 |
|
Confidence |
地理編碼位置結果的信賴等級相符。 搭配比對程式代碼使用此值,以判斷比對的更完整資訊。 地理編碼位置的信心是以許多因素為基礎,包括地理編碼位置和使用者位置的相對重要性。如果指定的話。 |
|
Feature |
指定 |
|
Features |
一個特色物件。 |
|
Features |
特徵特性。 |
|
Feature |
功能的類型必須是Feature。 |
|
Geocode |
一個地理代碼點。 |
|
Geocoding |
從成功的地理編碼呼叫傳回此物件 |
|
Geo |
指定 |
|
Geo |
有效的 |
| Intersection |
結果的位址。 |
|
Match |
一個代表配對代碼的枚舉。 |
|
Usage |
一個代表使用類型的枚舉。 |
Address
結果的位址
| 名稱 | 類型 | Description |
|---|---|---|
| addressLine |
string |
包含街道名稱和號碼的 AddressLine |
| adminDistricts |
地址的國家或地區中的細分名稱。 此元素通常被視為第一個命令系統管理細分,但在某些情況下,它也會包含國家/地區、相依性或區域的第二、第三或第四個順序細分。 |
|
| countryRegion |
國家或地區及其名稱和 ISO 代碼。 |
|
| formattedAddress |
string |
格式化地址屬性 |
| intersection |
結果的位址。 |
|
| locality |
string |
Locality 屬性 |
| neighborhood |
string |
鄰里物業 |
| postalCode |
string |
郵遞區號屬性 |
| streetName |
string |
formattedAddress 中的街道名稱 |
| streetNumber |
string |
街道上的號碼(如果可用),來自 formattedAddress |
AddressAdminDistrictsItem
地址的國家或地區中的細分名稱。
| 名稱 | 類型 | Description |
|---|---|---|
| name |
string |
對應 adminDistrict 字段的名稱,若為 adminDistrict[0],這可能是州名的完整名稱,例如 Washington、For adminDistrict[1],這可能是該縣的完整名稱 |
| shortName |
string |
對應 adminDistrict 字段的簡短名稱,針對 adminDistrict[0],這可能是州名稱的簡短名稱,例如 WA,對於 adminDistrict[1],這可能是縣的簡短名稱 |
AddressCountryRegion
國家或地區及其名稱和 ISO 代碼。
| 名稱 | 類型 | Description |
|---|---|---|
| ISO |
string |
國家/地區的 ISO |
| name |
string |
國家/地區名稱 |
Azure.Core.Foundations.Error
error 物件。
| 名稱 | 類型 | Description |
|---|---|---|
| code |
string |
其中一組伺服器定義的錯誤碼。 |
| details |
導致此錯誤之特定錯誤的詳細數據陣列。 |
|
| innererror |
物件,包含與目前對象有關錯誤更具體的資訊。 |
|
| message |
string |
錯誤的人類可讀取表示法。 |
| target |
string |
錯誤的目標。 |
Azure.Core.Foundations.ErrorResponse
包含錯誤詳細數據的回應。
| 名稱 | 類型 | Description |
|---|---|---|
| error |
error 物件。 |
Azure.Core.Foundations.InnerError
物件,包含有關錯誤的更特定資訊。 根據 Azure REST API 指引 - https://aka.ms/AzureRestApiGuidelines#handling-errors。
| 名稱 | 類型 | Description |
|---|---|---|
| code |
string |
其中一組伺服器定義的錯誤碼。 |
| innererror |
內部錯誤。 |
CalculationMethodEnum
用來計算地理編碼點的方法。
| 值 | Description |
|---|---|
| Interpolation |
使用插值將地理編碼點與道路上的點進行匹配。 |
| InterpolationOffset |
地理編碼點使用插值與道路上的點進行匹配,並使用額外的偏移量將點移動到街道一側。 |
| Parcel |
地理編碼點已與宗地中心匹配。 |
| Rooftop |
地理編碼點與建築物的屋頂匹配。 |
ConfidenceEnum
地理編碼位置結果的信賴等級相符。 搭配比對程式代碼使用此值,以判斷比對的更完整資訊。
地理編碼位置的信心是以許多因素為基礎,包括地理編碼位置和使用者位置的相對重要性。如果指定的話。
| 值 | Description |
|---|---|
| High |
如果置信度設置為 如果請求包含位置或視圖,則排名可能會相應更改。 例如,對“Paris”的位置查詢會可靠地 |
| Medium |
在某些情況下,返回的匹配項可能與請求中提供的資訊不在同一級別。 例如,請求可以指定地址資訊,而地理編碼服務可能只能匹配郵遞郵遞編碼。 在這種情況下,如果地理編碼服務具有郵遞區編碼與數據匹配的置信度,則置信度設置為, 如果查詢中的位置資訊不明確,並且沒有其他資訊來對位置進行排名(例如使用者位置或位置的相對重要性),則置信度設定為 如果查詢中的位置資訊未提供足夠的資訊來對特定位置進行地理編碼,則可能會傳回不太精確的位置值,並將置信度設定為 |
| Low |
低 |
FeatureCollectionEnum
指定 GeoJSON 類型。 唯一支援的物件類型是 FeatureCollection。 如需詳細資訊,請參閱 RFC 7946。
| 值 | Description |
|---|---|
| FeatureCollection |
指定 |
FeaturesItem
一個特色物件。
| 名稱 | 類型 | Description |
|---|---|---|
| bbox |
number[] (double) |
周框方塊。 使用的投影 - EPSG:3857。 如需詳細資訊,請參閱 RFC 7946。 |
| geometry |
有效的 |
|
| id |
string |
傳回之功能的標識碼 |
| properties |
特徵特性。 |
|
| type |
功能的類型必須是Feature。 |
FeaturesItemProperties
特徵特性。
| 名稱 | 類型 | Description |
|---|---|---|
| address |
結果的位址 |
|
| confidence |
地理編碼位置結果的信賴等級相符。 搭配比對程式代碼使用此值,以判斷比對的更完整資訊。 地理編碼位置的信心是以許多因素為基礎,包括地理編碼位置和使用者位置的相對重要性。如果指定的話。 |
|
| geocodePoints |
地理編碼點的集合,其計算方式和建議的使用方式不同。 |
|
| matchCodes |
一或多個比對程式代碼值,代表回應中每個位置的地理編碼層級。 例如,具有 同樣地,具有 可能的值為:
|
|
| type |
string |
其中之一:* 地址 * 路障 * 道路交叉口 * 社區 * 有人居住的地方 * 郵遞區號1 * 行政區1 * 行政區2 * 國家區域 |
FeatureTypeEnum
功能的類型必須是Feature。
| 值 | Description |
|---|---|
| Feature |
指定feature物件類型 |
GeocodePointsItem
一個地理代碼點。
| 名稱 | 類型 | Description |
|---|---|---|
| calculationMethod |
用來計算地理編碼點的方法。 |
|
| geometry |
有效的 |
|
| usageTypes |
地理編碼點的最佳使用。 每個地理編碼點都會定義為 |
GeocodingResponse
從成功的地理編碼呼叫傳回此物件
| 名稱 | 類型 | Description |
|---|---|---|
| features |
查詢回傳出一系列特徵。 |
|
| nextLink |
string |
是傳回之功能下一頁的連結。 如果它是最後一頁,則沒有此欄位。 |
| type |
指定 |
GeoJsonObjectType
指定 GeoJSON 類型。 必須是九個有效的 GeoJSON 物件類型之一 - Point、MultiPoint、LineString、MultiLineString、Polygon、MultiPolygon、GeometryCollection、Feature 和 FeatureCollection。
| 值 | Description |
|---|---|
| Point |
|
| MultiPoint |
|
| LineString |
|
| MultiLineString |
|
| Polygon |
|
| MultiPolygon |
|
| GeometryCollection |
|
| Feature |
|
| 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
一個代表配對代碼的枚舉。
| 值 | Description |
|---|---|
| Good |
好 |
| Ambiguous |
不明確 |
| UpHierarchy |
上層階級 |
UsageTypeEnum
一個代表使用類型的枚舉。
| 值 | Description |
|---|---|
| Display |
顯示器 |
| Route |
路由 |