Adding Data
It’s easy to add data from a range of sources to your mapbox map.
- Vector (from your data page on mapbox)
- Raster (from your data page on mapbox)
- GeoJSON from your server/another website
- Images/Videos
Must use asynchronous call.
This is a way to keep code from running until some event occurs.
map.on('load', function(){
// DO STUFF HERE
});
In the ‘DO STUFF HERE’ area we want to do two things.
- Add the data source - where are we pulling data from to put in our site?
- Draw the data.
How do we do this? Let’s look at the API to see what the addSource() and addLayer() methods do!
https://www.mapbox.com/mapbox-gl-js/api/