Adding GeoJSON to a Mapbox Style
By @RobLabs
Add your own Geo Data
In previous posts we talked about Mapbox Styles and GeoJSON.
Now we want to put these two concepts together. Suppose we have a GeoJSON that contains points of interest in Flagstaff, Arizona. One of the features is the tallest peak in the Coconino National Forest.
{
"type": "Feature",
"properties": {
"name": "Humphreys Peak"
},
"geometry": {
"coordinates": [
-111.677946,
35.346362
],
"type": "Point"
}
}
Mapbox Studio
Steps to add this GeoJSON into Mapbox.com/studio and style this point feature directly in Studio.
- You can drag your GeoJSON directly into studio
- Navigate to Datasets and drag your GeoJSON directly into the Datasets view
- Once its uploaded, click on
Start editing
- Look around the Datasets view and add any Points, LinesStrings or Polygons you want
- Save and export to a Tileset
- View the Tileset and click on
Add to Style
- Choose an existing or new style
For example
- Add our Points as either a
Circle
or aSymbol
. Do this so you can see the difference between these two types - Be sure to access the properties of your data set. In our case we can access the Feature
name
- Adjust properties for
Color
,Halo color
andHalo width
to give a great label effect - See a live sample at CodePen.io/roblabs
See how it looks in
- Streets Mapbox Style
- Satellite + Streets Mapbox Style
- Outdoors Mapbox Style