How to use the @hpcc-js/leaflet-shim.HeatLayer function in @hpcc-js/leaflet-shim

To help you get started, we’ve selected a few @hpcc-js/leaflet-shim examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hpcc-systems / Visualization / packages / map / src / leaflet / HeatLayer.ts View on Github external
this.style("opacity", this.opacity());
        const columns = this.columns();
        const latIdx = this.latitudeColumn_exists() ? columns.indexOf(this.latitudeColumn()) : 0;
        const longIdx = this.longitudeColumn_exists() ? columns.indexOf(this.longitudeColumn()) : 1;
        const weightIdx = columns.indexOf(this.weightColumn());
        this.clear();
        let bounds: LatLngBounds;
        const data = this.data().filter(row => !this.omitNullLatLong() || (!!row[latIdx] && !!row[longIdx])).map(row => {
            if (!bounds) {
                bounds = new LatLngBounds([row[latIdx], row[longIdx]]);
            } else {
                bounds.extend([row[latIdx], row[longIdx]]);
            }
            return [row[latIdx], row[longIdx], this.weightColumn_exists() ? row[weightIdx] : 0.5];
        });
        const heat = new LHeatLayer(data, {
            minOpacity: this.minOpacity(),
            max: this.max(),
            radius: this.radius(),
            blur: this.blur(),
            gradient: this.gradient() as any
        });
        (heat as any).getBounds = () => {
            return bounds;
        };
        this.add(heat);
    }
}