geocode()
住所を緯度経度にします。表記ゆれ・タイポ・旧市町村名も解決します。
geocode(address: string): Promise<GeocodeResult>
住所を入力
📍住所を入力すると、ここに結果が出ます
引数・レスポンス・読み方
引数
| 名前 | 型 | 既定 | 説明 |
|---|---|---|---|
| address必須 | string | — | 住所文字列。都道府県の省略・表記ゆれ・カナ入力・タイポ・旧市町村名を許容します。 |
レスポンス
GeocodeResult
| 名前 | 型 | 既定 | 説明 |
|---|---|---|---|
| candidates | Candidate[] | — | 候補。解決の深さとスコアの順。 |
| attribution | string[] | — | 出典表示。表示義務があります。 |
Candidate
| 名前 | 型 | 既定 | 説明 |
|---|---|---|---|
| address | string | — | 正規化された住所表記。 |
| lat / lng | number | — | 緯度経度(JGD2011)。 |
| matchLevel | 'rsdt' | 'block' | 'parcel' | 'oaza' | 'city' | 'pref' | — | どこまで解決できたか。 |
| accuracy | 'surveyed' | 'legacy' | 'representative' | — | その座標の品質。 |
| score | number | — | 一致率 0〜1。完全一致 1.0 / カナ 0.9 / タイポ 0.6。 |
| system | 'residential' | 'parcel' | — | 住居表示系か地番系か。 |
| components | AddressComponents | — | 住所の分割結果(pref / city / oaza / chome / block / rsdt など)。 |
| building | string? | — | 切り離した建物名・部屋番号。 |
| machiazaId | string? | — | 町字ID。住所文字列より安定した不変キー。 |
読み方
matchLevel — どこまで解決できたか
rsdt 号(住居表示)
block 番(街区)
parcel 筆(地番)
oaza 町字
city 市区町村
pref 都道府県
accuracy — その座標の品質
surveyed 実測点
legacy 公図由来。数十m ずれうる
representative 代表点。目的地の点ではない
listPrefectures()
都道府県47件を取ります。代表点の緯度経度つき。
listPrefectures(): Promise<PrefecturesResult>
実行
🗾「実行する」を押すと、ここに結果が出ます
引数・レスポンス
引数
| 名前 | 型 | 既定 | 説明 |
|---|---|---|---|
| — | — | — | 引数はありません。 |
レスポンス
PrefecturesResult
| 名前 | 型 | 既定 | 説明 |
|---|---|---|---|
| prefectures | Prefecture[] | — | 都道府県コード順。47件。 |
| attribution | string[] | — | 出典表示。 |
Prefecture
| 名前 | 型 | 既定 | 説明 |
|---|---|---|---|
| code | string | — | 都道府県コード2桁("01"〜"47")。 |
| name | string | — | 都道府県名。 |
| lat / lng | number | — | 代表点の緯度経度。 |
listMunicipalities()
都道府県から市区町村を取ります。
listMunicipalities(pref, options?):
Promise<MunicipalitiesResult>
都道府県を選ぶ
切り替わるのは政令指定都市20市だけです。wards
は行政区ごとに1件(横浜市なら18件)、nested
は市1件に区をまとめます。郡名は含めません。
🏙都道府県を選ぶと、ここに結果が出ます
引数・レスポンス
引数
| 名前 | 型 | 既定 | 説明 |
|---|---|---|---|
| pref必須 | string | number | — | コード(1〜47 / "01")または名称("神奈川県" / "神奈川")。解決できなければ空配列を返します。 |
| options.designatedCity | 'wards' | 'nested' | 'wards' | 政令指定都市20市の行政区の並べ方。 |
レスポンス
MunicipalitiesResult
| 名前 | 型 | 既定 | 説明 |
|---|---|---|---|
| municipalities | Municipality[] | — | 団体コード順。 |
| attribution | string[] | — | 出典表示。 |
Municipality
| 名前 | 型 | 既定 | 説明 |
|---|---|---|---|
| municipality | string | — | 市区町村名。行政区の場合は市名("横浜市")。 |
| ward | string[]? | — | 政令指定都市の行政区。政令市以外では省略されます。 |
| lat / lng | number | — |
代表点。この1件が指す団体のものです。wards
なら行政区(横浜市鶴見区)、nested
なら市そのもの(横浜市)の点になります。
|
nearestStationsByAddress()
住所から最寄り駅を取ります。全国10,465駅。
nearestStationsByAddress(address, options?):
Promise<…>
住所を入力
🚉住所を入力すると、ここに結果が出ます
引数・レスポンス
引数
| 名前 | 型 | 既定 | 説明 |
|---|---|---|---|
| address必須 | string | — | 住所文字列。内部で geocode() に渡します。 |
| options.limit | number | 10 | 返す件数。 |
| options.groupByStation | boolean | false | 乗換駅を1件にまとめるか。false だと乗り入れ路線の数だけ並びます。 |
| options.maxDistance | number? | — | この距離[m]より遠い駅を返しません。 |
レスポンス
| 名前 | 型 | 既定 | 説明 |
|---|---|---|---|
| candidate | Candidate | null | — | 住所の解決結果。解決できなければ null。 |
| stations | NearbyStation[] | — | 近い順。 |
| attribution | string[] | — | 出典表示。 |
NearbyStation
| 名前 | 型 | 既定 | 説明 |
|---|---|---|---|
| station | Station | — | 駅。 |
| distance | number | — | 指定座標からの直線距離[m]。徒歩の経路距離ではありません。 |
Station
| 名前 | 型 | 既定 | 説明 |
|---|---|---|---|
| code | number | — | 駅コード。 |
| groupCode | number | — | 同一駅グループ。乗換で結ばれる駅どうしで同じ値。 |
| name | string | — | 駅名。 |
| lineCode / lineName | number / string | — | 路線。 |
| company | string | — | 事業者名。 |
| pref | number | — | 都道府県コード 1〜47。 |
| postalCode | string | — | 郵便番号(ハイフンなし7桁)。 |
| address | string | — | 住所。 |
| lat / lng | number | — | 緯度経度。 |
listLines() / listStations()
都道府県から路線、路線から駅を取ります。
listLines(pref) → listStations({ pref, line })
都道府県 → 路線 の順に選ぶ
駅は路線順に並びます。分岐のある路線だけ、分岐箇所で順序が飛びます。
🚃都道府県と路線を選ぶと、ここに結果が出ます
引数・レスポンス
引数
listLines(pref)
| 名前 | 型 | 既定 | 説明 |
|---|---|---|---|
| pref必須 | string | number | — | コードまたは名称。その都道府県に駅がある路線だけを返します。 |
listStations(query?)
| 名前 | 型 | 既定 | 説明 |
|---|---|---|---|
| query.pref | string | number? | — | 都道府県で絞り込み。省略すると全国。 |
| query.line | number? | — | 路線コードで絞り込み。 |
レスポンス
LinesResult
| 名前 | 型 | 既定 | 説明 |
|---|---|---|---|
| lines | Line[] | — | 路線コード順。 |
| attribution | string[] | — | 出典表示。 |
Line
| 名前 | 型 | 既定 | 説明 |
|---|---|---|---|
| code | number | — | 路線コード。 |
| name | string | — | 路線名。 |
| company | string | — | 事業者名。 |
StationsResult
| 名前 | 型 | 既定 | 説明 |
|---|---|---|---|
| stations | Station[] | — | 路線上の並び順。 |
| attribution | string[] | — | 出典表示。 |