Add per-POI travel time filtering and fix heatmap color stops
Replace the single global max travel time filter with per-POI filters. Each POI gets its own travel mode selector and max minutes input in the filter panel. Listings must satisfy ALL active filters (AND logic). Fix Mapbox "Input is not a number" error by ensuring color stops are always strictly monotonic (guard min === max) and always set (even when no valid metric values exist). Also filter Infinity values from the color scale computation. Widen the filter panel from w-64 to w-80.
This commit is contained in:
parent
81d31eaecf
commit
07d4fa5f84
5 changed files with 193 additions and 17 deletions
|
|
@ -99,18 +99,24 @@ export function Map(props: MapProps) {
|
|||
.map(function (d: PropertyFeature) {
|
||||
return (d.properties as Record<string, unknown>)[metricMode] as number;
|
||||
})
|
||||
.filter(function (v: number) { return typeof v === 'number' && v > 0; })
|
||||
.filter(function (v: number) { return typeof v === 'number' && isFinite(v) && v > 0; })
|
||||
.sort(function (a: number, b: number) { return a - b; });
|
||||
|
||||
if (values.length > 0) {
|
||||
const minIndex = Math.round(values.length * PERCENTILE_CONFIG.MIN_BOUND);
|
||||
const maxIndex = Math.round(values.length * PERCENTILE_CONFIG.MAX_BOUND);
|
||||
const min = values[minIndex];
|
||||
const max = values[maxIndex];
|
||||
// Ensure max > min so color stops are strictly monotonic
|
||||
const max = Math.max(values[maxIndex], min + 1);
|
||||
|
||||
makeLegend(colorScheme, min, max);
|
||||
const colorStopsValue = calculateColorStops(colorScheme, min, max);
|
||||
heatmap.setColorStops(colorStopsValue);
|
||||
} else {
|
||||
// Set safe default stops so stale stops from a previous metric don't cause
|
||||
// Mapbox expression errors when the hexgrid produces cells with different value ranges
|
||||
const colorStopsValue = calculateColorStops(colorScheme, 0, 1);
|
||||
heatmap.setColorStops(colorStopsValue);
|
||||
}
|
||||
|
||||
heatmap.update();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue