Developing a web GPX viewer with Mapbox
For this recipe, we will use the way points dataset from Chapter 3, Working with Vector Data – The Basics. Refer to the script in the recipe named Working with GPS data to learn how to import .gpx
files tracks into PostGIS. You will also need a Mapbox token; for this, go to their site (https://www.mapbox.com) and sign up for one.
How to do it...
- To prepare the data for Mapbox's GeoJSON format, export the table tracks from Chapter 3, Working with Vector Data – The Basics using
ogr2ogr
with the following code:
ogr2ogr -f GeoJSON tracks.json \ "PG:host=localhost dbname=postgis_cookbook user=me" \ -sql "select * from chp03.tracks
- Remove the
crs
definition line on the new.json
with your favorite editor:
![](https://static.packt-cdn.com/products/9781788299329/graphics/ce6f91ff-fad1-4b77-8947-d88260ff0fe1.png)
- Go to your Mapbox account and upload in the Datasets menu the
tracks.json
file. After a successful upload, you will see the following message:
![](https://static.packt-cdn.com/products/9781788299329/graphics/e920b000-03a0-4272-93aa-f536ca71190f.png)
- Create the dataset and export it to a tileset:
![](https://static.packt-cdn.com/products/9781788299329/graphics/18f0713c-086d-4cd0-907a-b856c94f605a.png)
- Now, create a new style with the outdoors template:
![](https://static.packt-cdn.com/products/9781788299329/graphics/4dc55a98-090e-47d8-b3d4-38ba3da4a8a2.png)
- Add...