Leaflet / Leaflet.heat

A tiny, simple and fast heatmap plugin for Leaflet.
http://leaflet.github.io/Leaflet.heat/demo
BSD 2-Clause "Simplified" License
1.56k stars 525 forks source link

maxZoom in leaflet #104

Open stefansc1 opened 6 years ago

stefansc1 commented 6 years ago

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)

donei34 commented 5 years ago

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

stefansc1 commented 5 years ago

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;
    }
});