O'Reilly logo

Leaflet.js Essentials by Paul Crickard III

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required