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

Heatmaps with Leaflet.heat

The first heatmap you will make will be a density heatmap, using the Leaflet.heat plugin. You can download the JavaScript plugin at https://github.com/Leaflet/Leaflet.heat. The following steps will walk you through creating your first heatmap:

  1. Using LeafletEssentials.html, add a reference to Leaflet.heat.js with either a URL to a remote copy or the path to your local copy, as shown in the following code:
    <script src="http://Leaflet.github.io/Leaflet.heat/dist/Leaflet-heat.js"></script> or,
    <script src="Leaflet-heat.js"></script>
  2. Add an array of points. Your points can contain additional information but must have the latitude and longitude as the first two elements. The following code shows you three points from the code. ...

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