control the opacity of heatmap using leaflet heatm

2019-03-04 08:11发布

问题:

I am using leaflet.js , heatmap plugin.

There is one tiny class called L.heatLayer (source code https://github.com/Leaflet/Leaflet.heat/blob/gh-pages/src/HeatLayer.js)

There is no option for opacity

The options are only

options: {
maxZoom: 18,
radius: 25,
blur: 15,
max: 1.0},

Is there any way I can control the opacity using this leaflet.js heatLayer ? Thank you very much

回答1:

You can do it through css. Heatmap is a canvas of class leaflet-heatmap-layer

.leaflet-heatmap-layer {
opacity: .5;
}