Air Traffic Tutorial
This tutorial requires Draw v1.16.1 or above.
In this tutorial, we will use the OpenSky API along with a map to display a live feed of real airplanes on a map.
- Encapsulate OpenSky API in bricks
- Place a marker per plane on a map
- Clicking on a plane shows a 3D view of its situation (impersonate plane)
- Scanning a QR code lets you pilot the 3D view of the plane with your mobile
OpenSky connector
- Create a new project and name it
OpenSky-yourName
so you can easily recognize it. This project will provide the means necessary to query the OpenSky project for flights in a given area and parse the results. We will query the OpenSky project through its rest API. - In the Specs & Doc tab, document your new project (it is a library to wrap OpenSky API in bricks).
Using the API, create a brick returning flights given latitude and longitude coordinates, as specified in the OpenSky rest API.
Guidance
Hint 1
Hint 2
Hint 3
A complete solution
- Note that we will be using all the bricks in this library, so make sure you make them public.
Flights View App
We will now put a marker for each flight on a map. For this, we will create a simple UI App with a map.
We then query OpenSky with the bricks from the library we just created, feeding a zone of 1 square degree around the center of the map.
Create a new project, name it
Air Traffic
, and open it.Got the
Dependencies
tab and add (drag and drop) dependencies: Commons, "OpenSky-yourName", Maps (mapbox)Go back to the
Folder
tab and create a newUI App
, name itFlights View
In the app home screen, search for the
Mapbox map
component and drop it in the screenYou now want to use the library we create earlier to place markers on the map. Either use the user's device GPS position or the center of the map as you starting coordinates for the query.
Guidance
Hint 1
Hint 2
Hint 3
A complete solution
Test
- Go back to your project's root and click on
Flights View
app menu in the top right corner. SelectRun in browser
to run your app in a new tab. - Go to the new tab. You should see a map. It can take up to 30 seconds for OpenSky web service to answer. But after that, you should see the markers in your area.
Bonus
- If you used the GPS position, change the Markers function so it uses the center of the map instead of the user's position.
Hints
Solution
Bear in mind that the speed of the markers update is mainly conditioned by the OpenSky API, use the network tab of the your browser's developer tools if needed.