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:
- 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:
- Create the dataset and export it to a tileset:
- Now, create a new style with the outdoors template:
- Add...