Creating a choropleth map with Leaflet

In the previous examples, you used heatmaps to color code a map based on the density or intensity of points. A choropleth map also measures the intensity or density of a statistical variable but within polygons. A popular choropleth map is the population density by county. Choropleth maps do not require any plugins, as was the case with the heatmap examples. A choropleth map is usually created by styling GeoJSON based on a property.

The GeoJSON data

When adding a large amount of GeoJSON data to a map, it is easier to place the code in a separate JavaScript file. This clears your HTML file of hundreds of lines of code, which makes it hard to focus on building the map. When you place the GeoJSON code in a JavaScript ...

Get Leaflet.js Essentials 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.