位置情報

検索サービス

Mapbox検索サービス は、下記のAPIで構成されている。

Geocoding
Mapbox Geocoding APIは、フォワードジオコーディングとリバースジオコーディングの2つのことを行う。
フォワードジオコーディングは、ロケーションのテキストを地理座標に変換する。例えば、東京駅を35.681461、139.766357に変換する。
リバースジオコーディングは、地理座標を地名に変換する。
例えば35.681461、139.766357を東京駅に変換する。これらの場所名が特異性があって、特定の座標に指定されている国や個人住所などは異なる。

フォワードジオコーディング

1.	GET /geocoding/v5/{endpoint}/{search_text}.json  

フォワードジオコーディングのクエリというタイプを使用すると、単一の場所を名前で検索し、適当な地理座標を返すことができる。

必須の引数 説明
endpointEndpoints section で記載されている通りに、これがmapbox.placesまたはmapbox.places-permanentの一つである。
search_text検索する機能である。 検索対象は住所や関心地名や都市名などである。関心地点を検索する場合、検索対象がカテゴリ名(「コーヒーショップ」など)である。 カテゴリの詳細については、Point of interest category coverage sectionを参照してください。 検索テキストは、URLエンコードされたUTF-8文字列として表現されるべき、セミコロン文字(オリジナルまたはURLエンコードされたもの)は禁止。検索テキストはデコードされた際は、スペースと句読点で区切られる最大20個の単語と数字、かつ最大256文字を含まないといけない。 フォワードジオコーディングリのクエストより返される座標の精度は、クエリ内の住所の形式によって影響を受ける可能性がある。住所の形式はAddress geocoding format guideを参照してください。

1.	# A basic forward geocoding request    
2.	# Find 東京   
3.	    
4.	$ curl "https://api.mapbox.com/geocoding/v5/mapbox.places/東京.json?access_token=pk.YOUR_TOKEN"    
5.	    
6.	# Find a town called '台東区' in a specific region    
7.	# Add the proximity parameter with local coordinates    
8.	# This ensures the town of 台東区, 東京 is in the results    
9.	    
10.	$ curl "https://api.mapbox.com/geocoding/v5/mapbox.places/台東区.json?proximity=139.7684594,35.7132211&access_token=pk.YOUR_TOKEN"  
11.	    
12.	# Limit the results to two results using the limit option    
13.	# Even though there are many possible matches    
14.	# for "東京 ", this query will only return two results.    
15.	   
16.	$ curl "https://api.mapbox.com/geocoding/v5/mapbox.places/東京 .json?limit=2&access_token=pk.YOUR_TOKEN"     

応答:フォワードジオコーディング
フォワードジオコーディングクエリのAPIレスポンスは、GeoJSON機能のコレクションをMapbox Geocoding Responseの形式で返す。 Geocoding APIからの応答はどのようにフォーマットされるか、は下記の通りである。
例:
東京を検索するリクエストに対して

1.	$ curl "https://api.mapbox.com/geocoding/v5/mapbox.places/東京.json?access_token=pk.YOUR_TOKEN"     

応答の結果は以下になる。

1.	{  
2.	    "type": "FeatureCollection",  
3.	    "query": [  
4.	        "東",  
5.	        "京"  
6.	    ],  
7.	    "features": [  
8.	        {  
9.	            "id": "place.8168711922111140",  
10.	            "type": "Feature",  
11.	            "place_type": [  
12.	                "place"  
13.	            ],  
14.	            "relevance": 1,  
15.	            "properties": {  
16.	                "wikidata": "Q1490"  
17.	            },  
18.	            "text": "東京都",  
19.	            "place_name": "Japan, 東京都東京都",  
20.	            "bbox": [  
21.	                139.562782,  
22.	                35.5206810340001,  
23.	                139.918904,  
24.	                35.8176797471922  
25.	            ],  
26.	            "center": [  
27.	                139.77,  
28.	                35.68  
29.	            ],  
30.	            "geometry": {  
31.	                "type": "Point",  
32.	                "coordinates": [  
33.	                    139.77,  
34.	                    35.68  
35.	                ]  
36.	            },  
37.	            "context": [  
38.	                {  
39.	                    "id": "region.15637623541111140",  
40.	                    "short_code": "JP-13",  
41.	                    "wikidata": "Q1490",  
42.	                    "text": "東京都"  
43.	                },  
44.	                {  
45.	                    "id": "country.12208545982530190",  
46.	                    "short_code": "jp",  
47.	                    "wikidata": "Q17",  
48.	                    "text": "Japan"  
49.	                }  
50.	            ]  
51.	        },  
52.	        {  
53.	            "id": "region.15637623541111140",  
54.	            "type": "Feature",  
55.	            "place_type": [  
56.	                "region"  
57.	            ],  
58.	            "relevance": 1,  
59.	            "properties": {  
60.	                "short_code": "JP-13",  
61.	                "wikidata": "Q1490"  
62.	            },  
63.	            "text": "東京都",  
64.	            "place_name": "東京都, Japan",  
65.	            "bbox": [  
66.	                136.069382,  
67.	                20.425019,  
68.	                153.986993,  
69.	                35.898523  
70.	            ],  
71.	            "center": [  
72.	                139.77,  
73.	                35.68  
74.	            ],  
75.	            "geometry": {  
76.	                "type": "Point",  
77.	                "coordinates": [  
78.	                    139.77,  
79.	                    35.68  
80.	                ]  
81.	            },  
82.	            "context": [  
83.	                {  
84.	                    "id": "country.12208545982530190",  
85.	                    "short_code": "jp",  
86.	                    "wikidata": "Q17",  
87.	                    "text": "Japan"  
88.	                }  
89.	            ]  
90.	        },  
91.	        {  
92.	            "id": "poi.446676599787",  
93.	            "type": "Feature",  
94.	            "place_type": [  
95.	                "poi"  
96.	            ],  
97.	            "relevance": 1,  
98.	            "properties": {  
99.	                "address": "羽田空港3-3-2",  
100.	                "wikidata": "Q204853",  
101.	                "landmark": true,  
102.	                "category": "airport",  
103.	                "maki": "airport"  
104.	            },  
105.	            "text": "東京国際空港",  
106.	            "place_name": "東京国際空港, 羽田空港3-3-2, 東京都, 東京都, Japan",  
107.	            "center": [  
108.	                139.780759,  
109.	                35.5508825  
110.	            ],  
111.	            "geometry": {  
112.	                "coordinates": [  
113.	                    139.780759,  
114.	                    35.5508825  
115.	                ],  
116.	                "type": "Point"  
117.	            },  
118.	            "context": [  
119.	                {  
120.	                    "id": "locality.13630201322488990",  
121.	                    "wikidata": "Q217234",  
122.	                    "text": "大田区"  
123.	                },  
124.	                {  
125.	                    "id": "place.8168711922111140",  
126.	                    "wikidata": "Q1490",  
127.	                    "text": "東京都"  
128.	                },  
129.	                {  
130.	                    "id": "region.15637623541111140",  
131.	                    "short_code": "JP-13",  
132.	                    "wikidata": "Q1490",  
133.	                    "text": "東京都"  
134.	                },  
135.	                {  
136.	                    "id": "country.12208545982530190",  
137.	                    "short_code": "jp",  
138.	                    "wikidata": "Q17",  
139.	                    "text": "Japan"  
140.	                }  
141.	            ]  
142.	        },  
143.	        {  
144.	            "id": "poi.1005022347970",  
145.	            "type": "Feature",  
146.	            "place_type": [  
147.	                "poi"  
148.	            ],  
149.	            "relevance": 1,  
150.	            "properties": {  
151.	                "wikidata": "Q2335057",  
152.	                "address": "新木場4-7-28",  
153.	                "landmark": true,  
154.	                "category": "airport",  
155.	                "maki": "airport"  
156.	            },  
157.	            "text": "東京ヘリポート",  
158.	            "place_name": "東京ヘリポート, 新木場4-7-28, 東京都, 東京都, Japan",  
159.	            "center": [  
160.	                139.838112,  
161.	                35.636561  
162.	            ],  
163.	            "geometry": {  
164.	                "coordinates": [  
165.	                    139.838112,  
166.	                    35.636561  
167.	                ],  
168.	                "type": "Point"  
169.	            },  
170.	            "context": [  
171.	                {  
172.	                    "id": "locality.11956902086641820",  
173.	                    "wikidata": "Q215175",  
174.	                    "text": "江東区"  
175.	                },  
176.	                {  
177.	                    "id": "place.8168711922111140",  
178.	                    "wikidata": "Q1490",  
179.	                    "text": "東京都"  
180.	                },  
181.	                {  
182.	                    "id": "region.15637623541111140",  
183.	                    "short_code": "JP-13",  
184.	                    "wikidata": "Q1490",  
185.	                    "text": "東京都"  
186.	                },  
187.	                {  
188.	                    "id": "country.12208545982530190",  
189.	                    "short_code": "jp",  
190.	                    "wikidata": "Q17",  
191.	                    "text": "Japan"  
192.	                }  
193.	            ]  
194.	        },  
195.	        {  
196.	            "id": "poi.489626272622",  
197.	            "type": "Feature",  
198.	            "place_type": [  
199.	                "poi"  
200.	            ],  
201.	            "relevance": 1,  
202.	            "properties": {  
203.	                "wikidata": "Q57965",  
204.	                "landmark": true,  
205.	                "address": "押上1-1-2",  
206.	                "category": "historic site, historic"  
207.	            },  
208.	            "text": "東京スカイツリー (Tokyo Skytree)",  
209.	            "place_name": "東京スカイツリー (Tokyo Skytree), 押上1-1-2, 東京都, 東京都, Japan",  
210.	            "center": [  
211.	                139.8107715,  
212.	                35.7100965  
213.	            ],  
214.	            "geometry": {  
215.	                "coordinates": [  
216.	                    139.8107715,  
217.	                    35.7100965  
218.	                ],  
219.	                "type": "Point"  
220.	            },  
221.	            "context": [  
222.	                {  
223.	                    "id": "locality.13079443429859380",  
224.	                    "wikidata": "Q235135",  
225.	                    "text": "墨田区"  
226.	                },  
227.	                {  
228.	                    "id": "place.8168711922111140",  
229.	                    "wikidata": "Q1490",  
230.	                    "text": "東京都"  
231.	                },  
232.	                {  
233.	                    "id": "region.15637623541111140",  
234.	                    "short_code": "JP-13",  
235.	                    "wikidata": "Q1490",  
236.	                    "text": "東京都"  
237.	                },  
238.	                {  
239.	                    "id": "country.12208545982530190",  
240.	                    "short_code": "jp",  
241.	                    "wikidata": "Q17",  
242.	                    "text": "Japan"  
243.	                }  
244.	            ]  
245.	        }  
246.	    ],  
247.	    "attribution": "NOTICE: © 2019 Mapbox and its suppliers. All rights reserved. Use of this data is subject to the Mapbox Terms of Service (https://www.mapbox.com/about/maps/). This response and the information it contains may not be retained. POI(s) provided by Foursquare."  
248.	}       

リバースジオコーディング

1.	GET /geocoding/v5/{endpoint}/{longitude},{latitude}.json     

リバースジオコーディングクエリのタイプを使用すると、単一の座標ペアで検索して、返り値は地理的な機能又はそのロケーションに存在する機能である。

必須の引数 説明
endpointEndpoints sectionで記載されている通りに、これがmapbox.placesとmapbox.places-permanentのいずれかである。
longitude,latitudeクエリされているロケーションを指定する経度と緯度のペアである。

1.	# A basic reverse geocoding request    
2.	# Retrieve places near a specific location    
3.	   
4.	$ curl "https://api.mapbox.com/geocoding/v5/mapbox.places/139.7684594,35.7132211.json?access_token=pk.YOUR_TOKEN"    
5.	    
6.	# Filter results to only include points of interest    
7.	    
8.	$ curl "https://api.mapbox.com/geocoding/v5/mapbox.places/139.7684594,35.7132211.json?types=poi&access_token=pk.YOUR_TOKEN"      

応答:リバースジオコーディング
リバースジオコーディングクエリのAPIレスポンスは、GeoJSON機能のコレクションをMapbox Geocoding Responseの形式で返す。Geocoding APIからの応答はどのようにフォーマットされるか、は下記の通りである。

東京といったロケーションを探すリクエストは以下の通りである。

1.	$ curl "https://api.mapbox.com/geocoding/v5/mapbox.places/139.7684594,35.7132211.json?access_token=pk.YOUR_TOKEN"          

応答の結果は以下のようになる。

1.	{  
2.	    "type": "FeatureCollection",  
3.	    "query": [  
4.	        139.7684594,  
5.	        35.7132211  
6.	    ],  
7.	    "features": [  
8.	        {  
9.	            "id": "poi.2525440845611",  
10.	            "type": "Feature",  
11.	            "place_type": [  
12.	                "poi"  
13.	            ],  
14.	            "relevance": 1,  
15.	            "properties": {  
16.	                "landmark": true,  
17.	                "address": "池之端2-1-45",  
18.	                "category": "indian restaurant, indian food, restaurant"  
19.	            },  
20.	            "text": "サルガム 不忍池前店",  
21.	            "place_name": "サルガム 不忍池前店, 池之端2-1-45, 東京都, 東京都, Japan",  
22.	            "center": [  
23.	                139.76842,  
24.	                35.713096  
25.	            ],  
26.	            "geometry": {  
27.	                "coordinates": [  
28.	                    139.76842,  
29.	                    35.713096  
30.	                ],  
31.	                "type": "Point"  
32.	            },  
33.	            "context": [  
34.	                {  
35.	                    "id": "locality.7249900001173090",  
36.	                    "wikidata": "Q232641",  
37.	                    "text": "台東区"  
38.	                },  
39.	                {  
40.	                    "id": "place.8168711922111140",  
41.	                    "wikidata": "Q1490",  
42.	                    "text": "東京都"  
43.	                },  
44.	                {  
45.	                    "id": "region.15637623541111140",  
46.	                    "short_code": "JP-13",  
47.	                    "wikidata": "Q1490",  
48.	                    "text": "東京都"  
49.	                },  
50.	                {  
51.	                    "id": "country.12208545982530190",  
52.	                    "short_code": "jp",  
53.	                    "wikidata": "Q17",  
54.	                    "text": "Japan"  
55.	                }  
56.	            ]  
57.	        },  
58.	        {  
59.	            "id": "locality.7249900001173090",  
60.	            "type": "Feature",  
61.	            "place_type": [  
62.	                "locality"  
63.	            ],  
64.	            "relevance": 1,  
65.	            "properties": {  
66.	                "wikidata": "Q232641"  
67.	            },  
68.	            "text": "台東区",  
69.	            "place_name": "台東区, 東京都, 東京都, Japan",  
70.	            "bbox": [  
71.	                139.762785,  
72.	                35.6947040000001,  
73.	                139.809714,  
74.	                35.7312180000001  
75.	            ],  
76.	            "center": [  
77.	                139.784778,  
78.	                35.712783  
79.	            ],  
80.	            "geometry": {  
81.	                "type": "Point",  
82.	                "coordinates": [  
83.	                    139.784778,  
84.	                    35.712783  
85.	                ]  
86.	            },  
87.	            "context": [  
88.	                {  
89.	                    "id": "place.8168711922111140",  
90.	                    "wikidata": "Q1490",  
91.	                    "text": "東京都"  
92.	                },  
93.	                {  
94.	                    "id": "region.15637623541111140",  
95.	                    "short_code": "JP-13",  
96.	                    "wikidata": "Q1490",  
97.	                    "text": "東京都"  
98.	                },  
99.	                {  
100.	                    "id": "country.12208545982530190",  
101.	                    "short_code": "jp",  
102.	                    "wikidata": "Q17",  
103.	                    "text": "Japan"  
104.	                }  
105.	            ]  
106.	        },  
107.	        {  
108.	            "id": "place.8168711922111140",  
109.	            "type": "Feature",  
110.	            "place_type": [  
111.	                "place"  
112.	            ],  
113.	            "relevance": 1,  
114.	            "properties": {  
115.	                "wikidata": "Q1490"  
116.	            },  
117.	            "text": "東京都",  
118.	            "place_name": "Japan, 東京都東京都",  
119.	            "bbox": [  
120.	                139.562782,  
121.	                35.5206810340001,  
122.	                139.918904,  
123.	                35.8176797471922  
124.	            ],  
125.	            "center": [  
126.	                139.77,  
127.	                35.68  
128.	            ],  
129.	            "geometry": {  
130.	                "type": "Point",  
131.	                "coordinates": [  
132.	                    139.77,  
133.	                    35.68  
134.	                ]  
135.	            },  
136.	            "context": [  
137.	                {  
138.	                    "id": "region.15637623541111140",  
139.	                    "short_code": "JP-13",  
140.	                    "wikidata": "Q1490",  
141.	                    "text": "東京都"  
142.	                },  
143.	                {  
144.	                    "id": "country.12208545982530190",  
145.	                    "short_code": "jp",  
146.	                    "wikidata": "Q17",  
147.	                    "text": "Japan"  
148.	                }  
149.	            ]  
150.	        },  
151.	        {  
152.	            "id": "region.15637623541111140",  
153.	            "type": "Feature",  
154.	            "place_type": [  
155.	                "region"  
156.	            ],  
157.	            "relevance": 1,  
158.	            "properties": {  
159.	                "short_code": "JP-13",  
160.	                "wikidata": "Q1490"  
161.	            },  
162.	            "text": "東京都",  
163.	            "place_name": "東京都, Japan",  
164.	            "bbox": [  
165.	                136.069382,  
166.	                20.425019,  
167.	                153.986993,  
168.	                35.898523  
169.	            ],  
170.	            "center": [  
171.	                139.77,  
172.	                35.68  
173.	            ],  
174.	            "geometry": {  
175.	                "type": "Point",  
176.	                "coordinates": [  
177.	                    139.77,  
178.	                    35.68  
179.	                ]  
180.	            },  
181.	            "context": [  
182.	                {  
183.	                    "id": "country.12208545982530190",  
184.	                    "short_code": "jp",  
185.	                    "wikidata": "Q17",  
186.	                    "text": "Japan"  
187.	                }  
188.	            ]  
189.	        },  
190.	        {  
191.	            "id": "country.12208545982530190",  
192.	            "type": "Feature",  
193.	            "place_type": [  
194.	                "country"  
195.	            ],  
196.	            "relevance": 1,  
197.	            "properties": {  
198.	                "short_code": "jp",  
199.	                "wikidata": "Q17"  
200.	            },  
201.	            "text": "Japan",  
202.	            "place_name": "Japan",  
203.	            "bbox": [  
204.	                122.835038,  
205.	                20.323095,  
206.	                154.087047,  
207.	                45.622887  
208.	            ],  
209.	            "center": [  
210.	                136,  
211.	                35  
212.	            ],  
213.	            "geometry": {  
214.	                "type": "Point",  
215.	                "coordinates": [  
216.	                    136,  
217.	                    35  
218.	                ]  
219.	            }  
220.	        }  
221.	    ],  
222.	    "attribution": "NOTICE: © 2019 Mapbox and its suppliers. All rights reserved. Use of this data is subject to the Mapbox Terms of Service (https://www.mapbox.com/about/maps/). This response and the information it contains may not be retained. POI(s) provided by Foursquare."  
223.	}          

Related post

  1. レイヤの処理-web

  2. Mapbox Directions-iOS

  3. Mapbox API-Web

  4. Mapbox 2020年4月更新情報

  5. MAPBOXのサテライト画像改良版がリリース

  6. MAPBOX NAVIGATION SDK Ver10がパブリックプレ…

PAGE TOP