On Mapbox, Leaflet, and Turf.js
The past year I’ve worked a lot with Google Maps. I thought Google Maps were awesome. They seem to know about every “Place” on the planet! So I was a little shy about having to use Mapbox for some front-end map manipulation.
I began by having a look around their API documentation available here. I saw a lot of things that I had no clue about. TileLayers, GridLayers, Controls, and a bunch of utils. It wasn’t until I had spent the better part of 2 days trying to build a type of geofence manager using it that I really understood how powerful these tools are.
It seems like someone out there in the open-source community has solved every problem I come across. I needed to allow users to draw some polygons on the map - Leaflet.draw will help you with that!
I then needed to perform some operations on groups of polygons, so using a standard JSON format called GeoJSON, I can pass my polygons to Turf.js and use their awesome GIS library to perform things like intersections, and merging of polygons.
Overall, in a few short days I have come to really like this open-souce community who work with GIS libraries. Turf even have super fast response times to GitHub issues!
Check out my other blog posts! If you found this post interesting, feel free to let me know either on Twitter (@Isaac_M_Jordan), or in the comments section below.
Enjoyed my post? Sign up to the newsletter to receive a small email when I post. No spam, I promise.
Noah Huntington on July 22, 2016, 1:48 p.m.
I share in your excitement of mapbox and opensource as well. I have built many read only applications using leaflet and mapbox. Only recently have I discovered turf js and the geoprocessing capabilities it adds to these great libraries. I am wondering you you dont mind sharing the application you describe in the article. I am tring to do something similar by adding points lines and polygons on the map with leaflet draw and passing them to turf. Have you succeeded in doing this? Thanks in advance!
testing on May 24, 2017, 1 p.m.
this is testing