CloudFunctions Google maps service
Waldo-gcp
Waldo-gcp 在 2015 時 Google I/O Extended Taipei 時分享過一個計算最佳路徑的微服務。在提供幾組 Google Maps 上有效的地址,透過 Google Maps Distance Matrix API 來計算出每一個點一點之間的旅行距離及旅行時間。再透過基因演算出計算出周遊一圈旅行最短路徑
| |
| |

CloudFunctions Google maps service
Google Cloud Functions is a lightweight compute solution for developers to create single-purpose, stand-alone functions that respond to Cloud events without the need to manage a server or runtime environment - Google Cloud Functions Documentation
Waldo-gcp 微服務中透過 flex runtime GAE Python 中的 library(googlemaps) 來呼叫 Google Maps Distance Matrix API. Google Function 在這很適合取代原來 Python 版本的 Google Maps Distance Matrix API.
Cloud functions 可以建立 Background Funtions, HTTP Functions + HTTP Triggers, Cloud Pub/Sub Triggers, Cloud Storage Triggers, Direct Triggers. 所以我們可以建立一個可以執行 Google Maps Distance Matrix API 的 Cloud Functions, 透過起 HTTP Triggers, Direct Triggers 即可以建立計算旅行路徑的距離及時間
Getting Started
Github repo: cage1016/cloudfunctions-google-maps-services
| |
修改 index.js 中 API Key, <YOUR-GCP-API-KEY>, 並確保你的 GCP 專案有啟用 Google Maps Distance Matrix API
| |
distanceMatrix background
修改
makefile中BUCKET=<YOUR-GCS-BUCKET>Google Cloud Storage Bucket, Bucket 為 Cloud Functions 上傳的位置
修改完依序執行即可
| |
distanceMatrix background
修改
https://<YOUR_REGION>-<YOUR_PROJECT_ID>.cloudfunctions.net/distanceMatrixHttpendpoint, endpoints 可由make deploy_http中得到
修改完依序執行即可
| |
CloudFunctions
