Playground
Playground copied to clipboard
Modify the weather app so that the `units` (for the measurement unit) query param is dependent on the current location.
Overview
- The weather app does an API call to OpenWeatherMap to get the current data.
- The endpoint requires
units
(metric
orimperial
) as one of the query parameters. - For instance, we can make an API call to an endpoint that gives the country code (e.g. US, GB, etc.) given the coordinates (latitude and longitude).
Mocked screenly.js
The coordinates are not that precise. They're autogenerated by GitHub Copilot.
const getCoordinates = (area) => {
switch (area) {
case 'San Francisco':
return [
'37.7749',
'-122.4194'
]
case 'Manila':
return [
'14.5995',
'120.9842'
]
case 'Dijon':
return [
'47.3220',
'5.0415'
]
case 'New York':
return [
'40.7128',
'-74.0060'
]
default:
return []
}
}
const screenly = {
metadata: {
coordinates: getCoordinates('New York'),
hardware: 'Screenly Player Max',
hostname: 'srly-abcdefghijklmno',
location: 'San Francisco, USA',
screen_name: 'Edge App Test',
screenly_version: 'v1.0.0',
tags: [
'All Screens'
]
},
settings: {
disable_analytics: false,
ga_api_key: 'mcd0n4ld5',
sentry_id: 'p4nd4expr355',
// Make sure to obfuscate the OpenWeatherMap API key as well.
openweathermap_api_key: '[redacted]',
}
}
Screenshots
San Francisco, CA, US
Manila, PH
Dijon, FR
New York, USA
Relevant GitHub issues and PRs
- Screenly/Playground#99
- Screenly/Playground#105