A cool thing happens
To summon Jekyll to a page, you use those six hyphens:
Put variables inside or don’t. Either way Jekyll will gobble it up and make something awesome. Jekyll doesn’t discriminate.
.geojson? Let’s try it.
A GeoJSON file has a lot of repetition – swap out different coordinates here and maybe a style change there. The pattern lends itself to building a template and adding variables.
All my adventure posts have coordinates that I use to build a static map header. I decided that I wanted to grab all those coordinates, weave them into a GeoJSON file, and then load it on a single adventure map.
To start, I worked on my loop and found that this was the best route:
I created the file:
adventures.geojson and added those six magical hyphens. Next, I wove and massaged until GeoJSON happened:
Then, I added a few conditional statements to make sure my data looked tight:
- Capture post year. I assigned a marker color based on the year the post was published.
- Evaluate size of coordinates array. I have at least one post with more than one set of coordinates. The logic is that if a post has one set of coordinates then its a
Pointor else it’s a
- Smart symbol. Based on a post’s tags, I added a symbol to its marker.
The map lives here, but hey, I’ll save you a trip:
My map looks tight and now any adventure post will automatically be added to my map.
A few things I would like to work on:
- Polish colored markers. Right now the markers are colored by year, but that’s not super intuitive. I would like to find a better way to differentiate.
- Polish MultiPoint. This could be styled slightly different to bear a relationship with all the points in the feature.
- Style a map for my site. Right now I’ve been using a map that I styled with Editor, but I should really get my hands dirty with Studio.
Can you tell that I work for Mapbox now? <3