Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Leaflet.js Essentials

You're reading from   Leaflet.js Essentials Create interactive, mobile-friendly mapping applications using the incredibly light yet powerful Leaflet.js platform.

Arrow left icon
Product type Paperback
Published in Aug 2014
Publisher
ISBN-13 9781783554812
Length 180 pages
Edition 1st Edition
Languages
Arrow right icon
Toc

Creating heatmaps with heatmap.js


Creating a heatmap that uses intensity can be accomplished in Leaflet using heatmap.js. You can get heatmap.js at http://www.patrick-wied.at/static/heatmapjs/index.html. This includes the plugins for leaflet.js and other mapping packages. The process to create the heatmap is similar to the previous example. The following steps will walk you through creating a heatmap:

  1. Using LeafletEssentials.html, add a reference to heatmap.js and heatmap-Leaflet with either a URL to a remote copy or the path to your local copy, as shown in the following code:

    <script type="text/javascript" src="http://www.patrick-wied.at/static/heatmapjs/src/heatmap.js"></script>
    <script type="text/javascript" src="http://www.patrick-wied.at/static/heatmapjs/src/heatmap-Leaflet"></script>
  2. Add a JavaScript object with the max value of the intensity and an array of data:

    Var myData={max: 46,
    data: [{lat: 33.5363, lon:-117.044, value: 1},{lat: 33.5608, lon:-117.24, value...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image