ブログ | 株式会社ゴーガ

ルート検索:出発地、目的地の指定は、Place IDの使用をお勧めします

作成者: goga|Feb 15, 2023 1:00:00 AM

皆様、こんにちは!
Google Maps Platform のプロフェッショナル集団、ゴーガです。

Google Maps Platform では、ルート、距離や時間が取得できるDirections API や Distance Matrix API が提供されています。

このAPIを使用する場合、出発地、目的地に緯度経度を使用することが可能ですが、より良い結果を得るためには、出発地、目的地に緯度経度を指定するのではなく、Place IDまたは、住所を使うことが推奨されています。

例えば、以下のようなAとBのように隣接した位置間でルート検索をする場合、緯度経度を使用すると、その緯度経度で指定した建物の中心から近い道を使用したルート検索結果が返ってきます。

実際には、Aの建物への入り口が緑の箇所であるため、
このルートでは、建物の裏側から始まるルートになってしまいます。
ここで、Place IDを使用すると、
以下のように建物へのアクセスを考慮したルートが返ってきます。

これは、Place IDを使用することで、Place IDが持つアクセスポイントを加味したルート検索が可能となるためです。このPlace ID(および住所)の使用は、ドキュメントでも推奨されております。
If you pass an address, the Directions service geocodes the string and converts it to a latitude/longitude coordinate to calculate directions. This coordinate may be different from that returned by the Geocoding API, for example a building entrance rather than its center.
 
Note: For efficiency and accuracy, use place ID's when possible. 
These ID's are uniquely explicit like a lat/lng value pair and provide geocoding benefits for routing such as access points and traffic variables. Unlike an address, ID's do not require the service to perform a search or an intermediate request for place details; therefore, performance is better.
なお、Place IDのみを取得するリクエストであれば、
無償で使用することが可能です。
ご不明な点がございましたら、お気軽にお問い合わせください。