Chapter 12. Leaflet Map Templates

In Chapter 7, we described several easy-to-learn drag-and-drop tools, such as Google My Maps and Datawrapper, to create several basic types of interactive maps. If you want to create more customized or advanced maps to stretch beyond the scope of those tool platforms, this chapter offers several code templates based on Leaflet, a powerful open source library for displaying interactive maps on desktop or mobile devices. We first introduced you to Leaflet when you learned how to edit and host code on GitHub in Chapter 10.

All of the Leaflet map templates in this chapter are summarized in Table 12-1. The first two templates are good for beginners, because they pull your map data from a linked Google Sheets table, and don’t require any coding skills, but you need to follow some detailed GitHub instructions. The first template, “Leaflet Maps with Google Sheets” is best for showing any combination of points, polylines, or polygons, with your choice of custom icons and colors, and the option to display a summary table of point data below your map. The second template, “Leaflet Storymaps with Google Sheets”, is best for guiding viewers through a point-by-point tour, with a scrolling narrative to display text, images, audio, video, or scanned map backgrounds. We specifically created both code templates for readers of this book, to fill a gap in maps offered on hosted platforms.

The remainder of the Leaflet templates are designed to improve your coding ...

Get Hands-On Data Visualization now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.