~/talk

Build a Web Map with Open Source Tools

slides:none on file

A working web map that finds the nearest Capital Bikeshare stations, shows walking directions to the station and a bike route between stations, and updates with draggable origin/destination markers. Uses Mapbox.js (Leaflet-based) plus styles from Mapbox Studio, serves vector tiles (protocol buffers) with raster fallback, loads station data as GeoJSON, and runs spatial ops with Turf.js closest-point; typical city view loads about 15 tiles and accounts report a free tier of roughly 8,000 free map views.

AI-written summary · about

  1. 0:00Start
  2. 1:08Oh my goodness, this talk was hard to write.
  3. 2:44I also want to reinforce the idea that maps are hard...
  4. 5:19First of all, the entire map is housed in a map container in a div.
  5. 5:41Mapbox.js contains a ton of useful web mapping functions.
  6. 5:53Chief among them is loading map tiles.
  7. 6:04"What are map tiles?" you ask?
  8. 7:31In particular, the raster tile.
  9. 8:12Only the tiles in the current map view are requested and loaded. This makes modern web maps super hella fast
  10. 8:46Raster tiles are available at preset zoom levels with a different set of tiles at each zoom.
  11. 9:49Zoor level 1:4 tiles for the World.
  12. 11:46More recently, we've graduated to vector tiles.
  13. 12:12Vector tiles are similar to raster tiles...
  14. 12:49Roads, parks, water bodies, bike paths, points of interest, state boundaries...
  15. 13:22all of this is vector data with attributes attached to it.
  16. 14:23Vector tiles store all of this information, attributes included, as protocol buffers, or PBF files.
  17. 14:44Protocol buffers are super lightweight and compact.
  18. 15:01So vector tiles are one of the super awesome open source components of web maps.
  19. 17:01And Mapbox.js is what makes them possible!
  20. 19:08Where did these map tiles come from?
  21. 20:07These tiles were created with our desktop design tool, Mapbox Studio.
  22. 21:03Using a styling lanquage called CartoCSS, you can style any vector data you wish.
  23. 28:27From Mapbox Studio, you can upload a style to your account and use it in Mapbox.js, like in this example.
  24. 30:14the custom style is being applied to the associated vector tiles to render tiled images in the container.
  25. 31:17Boom! Tiles in a map!
  26. 32:25In the code, we create a marker icon with the L.mapbox.marker.icon constructor and add it to an L.marker object.
  27. 33:08The styling properties for the icon come from Maki, an icon font, and the Mapbox simplestyle-spec.
  28. 33:40This whole process is made up of tiny, self-contained components
  29. 33:57We also give the marker a location to draw itself and flag it as draggable so we can change the starting point of our trip.
  30. 34:13We then create a second marker that has a different style but is also draggable.
  31. 35:07Then we add both of them to the map.
  32. 35:50When we move the markers, there are some directions that appear on the map.
  33. 36:11That's actually four separate things the map is doing.
  34. 36:29Locating the nearest station to each marker
  35. 36:52GeoJSON is an extension of JSON, which stands for JavaScript Object Notation.
  36. 38:16Because GeoJSON is just JavaScript, it can easily be used in web maps!
  37. 40:28Just to digress into one of the many silly nuances of web mapping...
  38. 42:38To do this, we use another awesome open source library called Turf.js.
  39. 43:17Turf.js is a spatial analysis library.
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.