Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
layerUpdate(map: Map) {
super.layerUpdate(map);
this._palette = this._palette.switch(this.paletteID());
if (this.useClonedPalette()) {
this._palette = this._palette.cloneNotExists(this.paletteID() + "_" + this.id());
}
const latFunc = this.cellFunc(this.latitudeColumn(), 0);
const longFunc = this.cellFunc(this.longitudeColumn(), 0);
const latLongFunc = (row): [number, number] => [+latFunc(row), +longFunc(row)];
const weightFunc = this.cellFunc(this.weightColumn(), 0);
const data: any[][] = this.data();
const extent = d3Extent(data, weightFunc);
const format = this.weightFormat() ? d3Format(this.weightFormat()) : _ => _;
this.clear();
data.forEach(row => {
const circle = new Marker(latLongFunc(row), {
icon: this.createIcon(weightFunc(row), this._palette(weightFunc(row), extent[0], extent[1]), format),
origRow: row
} as any).on("click", e => this.clickHandler(e, row));
circle.bindTooltip("Weight: " + weightFunc(row));
this.add(circle);
});
}
updateHexagons() {
this._palette = this._palette.switch(this.paletteID());
if (this.useClonedPalette()) {
this._palette = this._palette.cloneNotExists(this.paletteID() + "_" + this.id());
}
const polyFunc = this.cellFunc(this.polygonColumn(), []);
const weightFunc = this.cellFunc(this.weightColumn(), 0);
const data = this.data();
const extent = d3Extent(data, weightFunc);
this.clear();
data.forEach(row => {
this.add(new Polygon(this.fixDateLine(polyFunc(row)).map(lngLat2LatLng), {
color: this._palette(extent[1], extent[0], extent[1]),
fillColor: this._palette(weightFunc(row), extent[0], extent[1]),
fillOpacity: this.opacity(),
weight: 1,
origRow: row
} as any).on("click", e => this.clickHandler(e, row)));
});
}