結果を特定のタイプに限定する
このチュートリアルでは、/revgeocode エンドポイントを使用して結果を特定のタイプに限定する方法を説明します。
手順
/revgeocode エンドポイントには任意パラメーター types があり、結果を特定のタイプに限定できます。
/revgeocode エンドポイントでサポートされている次の結果タイプのフィルター値を使用できます。
address- リクエストで指定された位置に最も近い住所 を取得します。検索アルゴリズムは正確な住所を返します。近くの住所が見つからない場合は、道路の結果または国固有の住所を返す場合があります。日本の場合は番地、英国などの一部の国の場合は高精度の郵便番号が返されます。street- リクエストで指定された位置に最も近い道路を取得します。area- リクエストで指定された位置のエリア情報を取得します。エリアはローカルまたは行政区画になります。city- リクエストで指定された位置の市区町村を取得します。
例として、at=50.1158056,8.6786751 のクエリを使用してみましょう。
GET https://revgeocode.search.hereapi.com/v1/
revgeocode
?at=50.1158056,8.6786751
&limit=3
&lang=en-US
&apiKey={YOUR_API_KEY}次のパラメーターを使用します。
- at - 座標で表される検索コンテキストの中心を指定します。
- limit - 返される結果の最大数。
- lang - BCP 47 に準拠した言語コードのリストから、結果のレンダリングに使用する言語を選択します。
- apiKey - APIキー。
注
このリクエストはAPIキー認証を使用します。HEREプラットフォームの認証オプションの詳細については、「Identity & Access Management Guide」(IDとアクセス管理ガイド)を参照してください。
結果タイプの制限がない場合、/revgeocodeエンドポイントはaddressやplaceなどのさまざまなタイプの結果を返します。
{
"items": [
{
"title": "Schillerstraße 15, 60313 Frankfurt am Main, Deutschland",
"id": "here:af:streetsection:9Lt20lMTkEV8MQcgHBlhWB:CgcIBCDiz4lQEAEaAjE1",
"resultType": "houseNumber",
"houseNumberType": "PA",
"address": {
"label": "Schillerstraße 15, 60313 Frankfurt am Main, Deutschland",
"countryCode": "DEU",
"countryName": "Deutschland",
"stateCode": "HE",
"state": "Hessen",
"countyCode": "F",
"county": "Frankfurt am Main",
"city": "Frankfurt am Main",
"district": "Innenstadt",
"street": "Schillerstraße",
"postalCode": "60313",
"houseNumber": "15"
},
"position": {
"lat": 50.11581,
"lng": 8.67859
},
"access": [
{
"lat": 50.11579,
"lng": 8.67873
}
],
"distance": 4,
"mapView": {
"west": 8.67868,
"south": 50.11558,
"east": 8.67917,
"north": 50.11681
}
},
{
"title": "Rahmhofstraße 2, 60313 Frankfurt am Main, Deutschland",
"id": "here:af:streetsection:u.HHRJ-pBkKi8DP.A7MeeD:CgcIBCCF-7tQEAEaATI",
"resultType": "houseNumber",
"houseNumberType": "PA",
"address": {
"label": "Rahmhofstraße 2, 60313 Frankfurt am Main, Deutschland",
"countryCode": "DEU",
"countryName": "Deutschland",
"stateCode": "HE",
"state": "Hessen",
"countyCode": "F",
"county": "Frankfurt am Main",
"city": "Frankfurt am Main",
"district": "Innenstadt",
"street": "Rahmhofstraße",
"postalCode": "60313",
"houseNumber": "2"
},
"position": {
"lat": 50.11566,
"lng": 8.67839
},
"access": [
{
"lat": 50.11559,
"lng": 8.67837
}
],
"distance": 27,
"mapView": {
"west": 8.67691,
"south": 50.11558,
"east": 8.67868,
"north": 50.11571
}
},
{
"title": "Schwarz Kaffeemobil",
"id": "here:pds:place:276u0yjj-ec90c8f5d8d79f27a07fb357ba5470c2",
"resultType": "place",
"address": {
"label": "Schwarz Kaffeemobil, Schillerstraße 21, 60313 Frankfurt am Main, Deutschland",
"countryCode": "DEU",
"countryName": "Deutschland",
"stateCode": "HE",
"state": "Hessen",
"countyCode": "F",
"county": "Frankfurt am Main",
"city": "Frankfurt am Main",
"district": "Innenstadt",
"street": "Schillerstraße",
"postalCode": "60313",
"houseNumber": "21"
},
"position": {
"lat": 50.11613,
"lng": 8.67825
},
"access": [
{
"lat": 50.11607,
"lng": 8.6788
}
],
"distance": 30,
"categories": [
{
"id": "100-1100-0010",
"name": "Kaffeehaus",
"primary": true
}
]
}
]
}エンド ユーザーが場所の結果に関心がない場合、顧客アプリケーションは次のように結果を address タイプに限定できます。
GET https://revgeocode.search.hereapi.com/v1/
revgeocode
?at=50.1158056,8.6786751
&types=address
&limit=3
&apiKey={YOUR_API_KEY}場所の結果は返されません。すべての結果が住所になります。
{
"items": [
{
"title": "Schillerstraße 15, 60313 Frankfurt am Main, Deutschland",
"id": "here:af:streetsection:9Lt20lMTkEV8MQcgHBlhWB:CgcIBCDiz4lQEAEaAjE1",
"resultType": "houseNumber",
"houseNumberType": "PA",
"address": {
"label": "Schillerstraße 15, 60313 Frankfurt am Main, Deutschland",
"countryCode": "DEU",
"countryName": "Deutschland",
"stateCode": "HE",
"state": "Hessen",
"countyCode": "F",
"county": "Frankfurt am Main",
"city": "Frankfurt am Main",
"district": "Innenstadt",
"street": "Schillerstraße",
"postalCode": "60313",
"houseNumber": "15"
},
"position": {
"lat": 50.11581,
"lng": 8.67859
},
"access": [
{
"lat": 50.11579,
"lng": 8.67873
}
],
"distance": 4,
"mapView": {
"west": 8.67868,
"south": 50.11558,
"east": 8.67917,
"north": 50.11681
}
},
{
"title": "Rahmhofstraße 2, 60313 Frankfurt am Main, Deutschland",
"id": "here:af:streetsection:u.HHRJ-pBkKi8DP.A7MeeD:CgcIBCCF-7tQEAEaATI",
"resultType": "houseNumber",
"houseNumberType": "PA",
"address": {
"label": "Rahmhofstraße 2, 60313 Frankfurt am Main, Deutschland",
"countryCode": "DEU",
"countryName": "Deutschland",
"stateCode": "HE",
"state": "Hessen",
"countyCode": "F",
"county": "Frankfurt am Main",
"city": "Frankfurt am Main",
"district": "Innenstadt",
"street": "Rahmhofstraße",
"postalCode": "60313",
"houseNumber": "2"
},
"position": {
"lat": 50.11566,
"lng": 8.67839
},
"access": [
{
"lat": 50.11559,
"lng": 8.67837
}
],
"distance": 27,
"mapView": {
"west": 8.67691,
"south": 50.11558,
"east": 8.67868,
"north": 50.11571
}
},
{
"title": "Große Eschenheimer Straße 13, 60313 Frankfurt am Main, Deutschland",
"id": "here:af:streetsection:VO7eTHzu807EUG7vuttz3D:EAIaAjEz",
"resultType": "houseNumber",
"houseNumberType": "interpolated",
"address": {
"label": "Große Eschenheimer Straße 13, 60313 Frankfurt am Main, Deutschland",
"countryCode": "DEU",
"countryName": "Deutschland",
"stateCode": "HE",
"state": "Hessen",
"countyCode": "F",
"county": "Frankfurt am Main",
"city": "Frankfurt am Main",
"district": "Innenstadt",
"street": "Große Eschenheimer Straße",
"postalCode": "60313",
"houseNumber": "13"
},
"position": {
"lat": 50.11562,
"lng": 8.67934
},
"access": [
{
"lat": 50.1156,
"lng": 8.67955
}
],
"distance": 52,
"mapView": {
"west": 8.67935,
"south": 50.11406,
"east": 8.67985,
"north": 50.1171
}
}
]
}エンド ユーザーがドライバーの所在番地を追跡している場合、顧客アプリケーションは次のように結果を street タイプに絞り込めます。
GET https://revgeocode.search.hereapi.com/v1/
revgeocode
?at=50.1158056,8.6786751
&types=street
&apiKey={YOUR_API_KEY}結果は最も近い道路になります。
{
"items": [
{
"title": "Schillerstraße, 60313 Frankfurt am Main, Deutschland",
"id": "here:af:streetsection:9Lt20lMTkEV8MQcgHBlhWB",
"resultType": "street",
"address": {
"label": "Schillerstraße, 60313 Frankfurt am Main, Deutschland",
"countryCode": "DEU",
"countryName": "Deutschland",
"stateCode": "HE",
"state": "Hessen",
"countyCode": "F",
"county": "Frankfurt am Main",
"city": "Frankfurt am Main",
"district": "Innenstadt",
"street": "Schillerstraße",
"postalCode": "60313"
},
"position": {
"lat": 50.1158,
"lng": 8.67874
},
"distance": 4,
"mapView": {
"west": 8.67868,
"south": 50.11558,
"east": 8.67917,
"north": 50.11681
}
}
]
}エンド ユーザーがエリアのみを探している場合、顧客アプリケーションは次のように結果を area タイプに限定できます。
GET https://revgeocode.search.hereapi.com/v1/
revgeocode
?at=50.1158056,8.6786751
&types=area
&apiKey={YOUR_API_KEY}/revgeocode エンドポイントは都市「Frankfurt am Main」を返します。
{
"items": [
{
"title": "Frankfurt am Main, Hessen, Deutschland",
"id": "here:cm:namedplace:20161003",
"resultType": "locality",
"localityType": "city",
"address": {
"label": "Frankfurt am Main, Hessen, Deutschland",
"countryCode": "DEU",
"countryName": "Deutschland",
"stateCode": "HE",
"state": "Hessen",
"countyCode": "F",
"county": "Frankfurt am Main",
"city": "Frankfurt am Main",
"postalCode": "60311"
},
"position": {
"lat": 50.11208,
"lng": 8.68341
},
"distance": 0,
"mapView": {
"west": 8.47268,
"south": 50.01526,
"east": 8.80043,
"north": 50.22721
}
}
]
}複数の値を指定できます。たとえば、「types=address,area」と指定すると、近くに住所がない場合は結果が住所またはエリアに限定され、場所は除外されます。
追加情報
/revgeocodeパラメーターの詳細については、「APIリファレンス」を参照してください。
さまざまなエンドポイントによるtypesフィルターのサポートの概要については、次を参照してください:結果タイプでフィルタリングする
先月の更新