Skip to content
Code samples that demonstrate how to integrate DeFROST services in different platforms.
JavaScript HTML Python Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Postman Collections
tests
.env.defaults
.gitignore
LICENSE
README.md
bundle.js
index.html
main.js
package-lock.json
package.json
webpack.config.js

README.md

DeFROST Code Examples

Demonstrates integration of DeFROST Snow Cover tiles and API in supported platforms:

  • OpenLayers 5.3, Leaflet 1.5 and Mapbox GL JS 1.2 for displaying snow cover tiles
  • JavaScript, Python and Curl for API requests

The test web app can be launched using npm.

Getting started

Setup your JWT Access and Refresh Tokens in the .env.defaults file. You can get them from DeFROST Account Dashboard. For the Mapbox GL JS example to work, you also need to set your Mapbox access token.

# .env.deaults, safe to commit
JWT_ACCESS_TOKEN=<YourJWTAccessTokenHere>
JWT_REFRESH_TOKEN=<YourJWTRefreshTokenHere>

DEFROST_MAPS_URL=https://maps.defrost.ch/{z}/{x}/{y}.png
TOKEN_REFRESH_URL=https://api.defrost.ch/v1/token/refresh/

MAPBOX_TOKEN=<YourMapboxTokenHere>

Launching the test app

When ready, install dependencies and run the app with the following commands:

npm install
npm run start:dev

This will trigger JavaScript bundle compilation using webpack. Once the Compiled successfully message appears on your terminal, access the app at localhost:8080 from your browser.

The test web application demonstrates DeFROST Snow Cover tiles integration, as well as making an API request using JavaScript. For the Python and Curl API tests, launch the files directly with your Python interpreter or from your terminal.

License

MIT

You can’t perform that action at this time.