Leaflet.heat icon indicating copy to clipboard operation
Leaflet.heat copied to clipboard

maxZoom in leaflet

Open stefansc1 opened this issue 5 years ago • 2 comments

maxZoom is a Leaflet option for TileLayers and GridLayers. To disable the heatmap's intensity scaling with zoom, I set maxZoom to the map's minimum zoom level. Now I cannot toggle the heatmap layer in the layer controls any more, because layer.options.maxZoom is checked for that (see https://github.com/Leaflet/Leaflet/blob/86bb4090c1b1b56165e40b62992750a4e7e2f963/src/control/Control.Layers.js#L402 for details).

Leaflet version: latest (1.3.3) Heatmap version: latest (0.2.0)

stefansc1 avatar Aug 08 '18 09:08 stefansc1

That way I personally fixed this exact same issue was to manually edit leaflet-heat.js and replace u = void 0 etc. with whatever maxzoom you want. Then in your main script and the options for the heatmap remove the maxzoom declaration

donei34 avatar Dec 19 '18 03:12 donei34

There are two other ways: when editing the leaflet-heat code anyway, you could change this.options.maxZoom to anything that is not used yet, like this.options_maxZoom, so it can still be set but does not interfere with the leaflet option for layers. Or you could overwrite how the layer control works (however, this disables zoom checking for all layers):

L.Control.Layers.include({
	_checkDisabledLayers: function (){
		return;
	}
});

stefansc1 avatar Jan 17 '19 10:01 stefansc1