A widget built using the iOS app Scriptable. It displays nearby Wikipedia articles and allows you to either read them or get Google Maps directions to them.
- Get an API key from Google.
- Make sure to enable Billing on the Google Cloud Project. Learn more here.
- Enable Google Maps Static API for your API key
- Download the Scriptable App for iOS.
- Copy and paste widget.js into a new script on the Scriptable app.
- Edit the script params section of the script to use your API key:
const scriptParams = {
apiKey: 'XXX', <--- Put the API key here!
forceWidgetView: false,
writeLogsIfException: false,
logPerformanceMetrics: false
}
- Create a new Scriptable widget on your home screen and edit it to use the script you downloaded.
- Enjoy!
Sometimes storing widget parameters in the script itself is too limiting. For reasons explained below the script will attempt to load parameters in this order:
- Parameters passed in from the widget on the home screen.
- This is great for displaying multiple of the same widget on your home screen. Think different locations, different sizes, etc.
- This is also great for sharing the script file without risking sharing sensitive information (API key).
- JSON file "./storage/scriptname.json".
- This is great when you are using tools that update the script's file regularly. For example, this developer tool updates scripts using Github. By storing the parameters in a file you won't have to go into the file and rewrite your parameters each time the file is downloaded/updated again.
- This is also useful for sensitive information (API key).
- Hard-coded parameters at the top of the file.
This is most typically an issue with Google Maps' account settings. If you copy-paste the Google Maps URL to your browser you will likely see this message:
"The Google Maps Platform server rejected your request. You must enable Billing on the Google Cloud Project at https://console.cloud.google.com/project/_/billing/enable Learn more at https://developers.google.com/maps/gmp-get-started"
We'll attempt to add better logs at some point in the future 👍.
There are three useful tools for debugging built-in to this script. They can all be turned on by setting their parameter to true. They are:
- forceWidgetView: Loads the widget even if run directly from scriptable. Useful for seeing the widget view's logs.
- writeLogsIfException: Writes the script's logs to a file if there is an exception. Be careful, right now it will overrite the file every time there is an exception.
- logPerformanceMetrics: Stores function performance metrics each time the script runs. Appends how long each function takes in milliseconds to a CSV if they are wrapped by the performanceWrapper.
If turned on, the script will write it's logs to the file system whenever it encounters a failure. The logs of the script are stored in the scriptable folder under storage/scriptname-logs.txt
.
Please note that the logs will be overwritten each time there is a new failure if this feature is turned on.
Here's an issue where the failure logs where useful.
If turned on, performance metrics are stored in a CSV file. They can be found in the scriptable folder under storage/scriptname-performance-metrics.csv
.
CSV files could be read directly or visualized in Excel and Google Sheets. They can also be read easily using the Charty app with this shortcut:
https://www.icloud.com/shortcuts/932366757e124075ae6f755da89563eb
Here's an investigation where the performance logs were useful: