Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to load the effect of Thermal Map in Leaflet

Shulou Source: shulou.com Published: 2022-06-01 03:37:20 09月11日 Update

This article mainly introduces how to load the heat map effect in Leaflet, which has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, let the editor take you to understand it.

Leaflet is an open source JavaScript class library for interactive maps on the desktop and mobile. The size of the JS library is about 38k after compression, and it has all the map functions that developers need.

Leaflet maintains the design idea of simplicity, performance and practicality. It works efficiently on all major desktop and mobile platforms and can extend plug-ins. It has a beautiful, easy-to-use and well-documented API, and a simple, easy-to-read source code.

Heatmap.js is a lightweight, easy-to-use js class library, through the library reference, you can easily create a heat map, the address on github is https://github.com/pa7/heatmap.js, which provides a number of examples, including Leaflet or Google Maps.

Load the thermal map on Leaflet, and there is a ready-made class library. The specific usage is as follows:

Reference heatmap.js, and then reference heatmap.js/plugins/leaflet-heatmap/leaflet-heatmap.js, and develop according to the sample code on example. The following is a sample development based on the actual data. For specific parameters, please see the page description on github.

/ / load the corresponding class library

Require (['leaflet-heatmap'], function (HeatmapOverlay) {

/ / json request data

$.getJSON ('sampledata/ta_school.json', function (data) {

/ / set parameters

Var cfg = {

Radius: .007

"maxOpacity": .65

"scaleRadius": true

"useLocalExtrema": true

LatField: 'cy'

LngField: 'cx'

ValueField: 'cnt'

}

/ / define the thermal map

Var heatmapLayer = new HeatmapOverlay (cfg)

HeatmapLayer.setData (data)

LayerControl.addOverlay (heatmapLayer, thermal map)

});

});

Thank you for reading this article carefully. I hope the article "how to load the Thermal Map effect in Leaflet" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Articles maps examples development effects parameters data desktop mobile practical beautiful code value usage interest function at the same time address size practicality Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info vpn Microsoft Docker Huawei