better heatmap

This commit is contained in:
Polen 2026-04-02 11:38:05 -04:00
parent 7715f7b92b
commit 2057a1cd48

View file

@ -169,28 +169,32 @@
document.getElementById('slider-label').textContent = Math.ceil(maxPrice) + '¢/L'; document.getElementById('slider-label').textContent = Math.ceil(maxPrice) + '¢/L';
// Build heatmap layer // Build heatmap layer
// Each point gets an intensity based on its price.
// We set a floor of 0.25 so cheap stations are still clearly visible,
// and use a high 'max' so overlapping stations don't oversaturate to red.
const heatData = stations const heatData = stations
.filter(s => s.regular > 0) .filter(s => s.regular > 0)
.map(s => { .map(s => {
const intensity = (s.regular - minPrice) / (maxPrice - minPrice); const t = (s.regular - minPrice) / (maxPrice - minPrice);
const intensity = 0.25 + t * 0.75; // range [0.25 .. 1.0]
return [s.lat, s.lng, intensity]; return [s.lat, s.lng, intensity];
}); });
heatLayer = L.heatLayer(heatData, { heatLayer = L.heatLayer(heatData, {
radius: 25, radius: 22,
blur: 20, blur: 25,
maxZoom: 12, maxZoom: 13,
max: 1.0, max: 3.0,
minOpacity: 0.35,
gradient: { gradient: {
0.0: '#313695', 0.0: '#313695',
0.1: '#4575b4', 0.15: '#4575b4',
0.2: '#74add1', 0.3: '#74add1',
0.3: '#abd9e9', 0.45: '#abd9e9',
0.4: '#e0f3f8', 0.55: '#fee090',
0.5: '#fee090', 0.7: '#fdae61',
0.6: '#fdae61', 0.8: '#f46d43',
0.7: '#f46d43', 0.9: '#d73027',
0.8: '#d73027',
1.0: '#a50026', 1.0: '#a50026',
} }
}); });