-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(firestore-geo-functions): updated documentation and icon (#5)
* docs(firestore-geo-functions): updated documentation and icon * Update PREINSTALL.md * Update extension.yaml to include tags --------- Co-authored-by: huangjeff5 <64040981+huangjeff5@users.noreply.github.com>
- Loading branch information
1 parent
c0ebecc
commit 0e71b56
Showing
3 changed files
with
43 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,56 @@ | ||
Use this extension to automatically update the latitude and longitude of an address, as well as the best driving time between two addresses, using the Google Maps API. | ||
## How This Extension Works | ||
|
||
It listens to specified fields in documents within a Firestore collection and updates the `latitude`, `longitude`, and `best driving time` as needed. | ||
Use this extension to perform geocoding operations on Firestore documents using the Geocoding API and travel time estimates using the Distance Matrix API. This extension can help you: | ||
|
||
### Features | ||
* Automatically deduce the latitude and longitude of an address | ||
* Figure out the best driving time between two addresses | ||
|
||
### Automatically retrieves latitude and longitude for an address. | ||
This feature listens to Firestore document creation/updates and updates geolocation information accordingly when a valid `address` has been added/updated in a document. | ||
The extension listens to specified fields in documents within a Firestore collection and updates the latitude, longitude, and best driving time fields as needed. | ||
|
||
To ensure best practices, if a document has been updated within the last 30 days, the extension will not update the geolocation information. | ||
On install, you will be asked to provide a Firestore collection. When documents are created or updated within that collection, a Cloud Function will trigger that calls Geocoding API to execute a geocoding operation. | ||
|
||
```js | ||
### Automatically retrieves latitude and longitude for an address | ||
|
||
This feature will geocode an address when a valid address has been added/updated in a document. | ||
|
||
```javascript | ||
admin.firestore().collection('address_book').add({ | ||
address: '1600 Amphitheatre Parkway, Mountain View, CA', | ||
}) | ||
}); | ||
``` | ||
|
||
### Calculates the best driving time between two addresses. | ||
To calculate the best driving time between two destinations, the extension feature to Firestore document creation/updates and updates `bestDrivingTime` information based on the provided `origin` and `destination` addresses. | ||
### If an origin and destination are provided to the collection, the extension calls the Distance Matrix API to calculate the best driving time between two addresses | ||
|
||
```js | ||
This extension will calculate bestDrivingTime information based on the provided origin and destination addresses. | ||
|
||
```javascript | ||
admin.firestore().collection('address_book').add({ | ||
origin: '1600 Amphitheatre Parkway, Mountain View, CA', | ||
destination: '85 10th Ave, New York, NY' | ||
}) | ||
}); | ||
``` | ||
|
||
### Supports exponential backoff for error handling. | ||
The extension uses exponential backoff guidelines through Cloud Tasks to ensure that it will continue trying to update the document data for any task. Learn more about this feature. | ||
### Implements Google Maps Platform Best Practices | ||
|
||
According to Google Maps Platform [Terms of Service](https://cloud.google.com/maps-platform/terms/maps-service-terms), geocode information cannot be stored for longer than 30 days. Whenever geocode information is retrieved for a Firestore document, a scheduled Cloud Task is created which will re-query the geocode information after 30 days. | ||
|
||
Whenever there are intermittent issues with the Google Maps Platform APIs, this extension implements automatic retries using an exponential backoff strategy as recommended [here](https://developers.google.com/maps/documentation/routes/web-service-best-practices#exponential-backoff). | ||
|
||
## Additional setup | ||
|
||
Before installing this extension, make sure that you've set up a [Cloud Firestore database](https://firebase.google.com/docs/firestore/quickstart) in your Firebase project. | ||
|
||
Additionally, make sure that you've enabled the [Geocoding API](https://developers.google.com/maps/documentation/geocoding/cloud-setup) and [Distance Matrix API](https://developers.google.com/maps/documentation/distance-matrix/cloud-setup#enabling-apis) for your project and obtained an [API key](https://developers.google.com/maps/documentation/geocoding/get-api-key). You will be asked to provide this API key during installation. | ||
|
||
You can read more about this feature [here](https://developers.google.com/maps/documentation/routes/web-service-best-practices#exponential-backoff) | ||
## Billing | ||
|
||
To install an extension, your project must be on the Blaze (pay as you go) plan. | ||
|
||
### Additional setup | ||
Before installing this extension, make sure that you've set up a Cloud Firestore database in your Firebase project. | ||
A valid Google Maps API key is required as part of the extension installation process. | ||
You will be charged a small amount (typically around $0.01/month) for the Firebase resources required by this extension (even if it is not used). | ||
|
||
#### Billing | ||
To install an extension, your project must be on the [Blaze (pay as you go) plan](https://firebase.google.com/pricing) | ||
This extension uses other Firebase and Google Cloud Platform services, which have associated charges if you exceed the service’s no-cost tier: | ||
|
||
- You will be charged a small amount (typically around $0.01/month) for the Firebase resources required by this extension (even if it is not used). | ||
- This extension uses other Firebase and Google Cloud Platform services, which have associated charges if you exceed the service’s no-cost tier: | ||
- Cloud Google Maps API | ||
- Cloud Firestore | ||
- Cloud Functions (Node.js 10+ runtime. [See FAQs](https://firebase.google.com/support/faq#extensions-pricing)) | ||
* [Geocoding API](https://developers.google.com/maps/documentation/geocoding/usage-and-billing) | ||
* [Distance Matrix API(https://developers.google.com/maps/documentation/distance-matrix/usage-and-billing) | ||
* Cloud Firestore | ||
* Cloud Functions (Node.js 14+ runtime. See [FAQs](https://firebase.google.com/support/faq#extensions-pricing)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.