From 4931d103643b86f6c428e6726852d51b1ca16ca8 Mon Sep 17 00:00:00 2001 From: Quincy Morgan <2046746+quincylvania@users.noreply.github.com> Date: Wed, 31 Jul 2024 13:39:19 -0400 Subject: [PATCH] Filter water trail pois to focus area --- js/mapController.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/js/mapController.js b/js/mapController.js index 7873643..fb7728e 100644 --- a/js/mapController.js +++ b/js/mapController.js @@ -979,6 +979,20 @@ function isSpecifiedExpressionForLens(lens, travelMode) { return specifiedAttributeExpression; } +function waterTrailPoisFilter(travelMode) { + var filter = ["all"]; + if (focusAreaGeoJson?.geometry?.coordinates?.length) { + filter.push(["within", focusAreaGeoJson]); + } + if (travelMode !== "canoe") { + filter.push([ + "any", + ["==", ["get", "waterway"], "waterfall"], + ]) + } + return filter.length > 1 ? filter : null; +} + function trailPoisFilter(travelMode) { var filter = [ "all", @@ -1347,10 +1361,7 @@ function updateTrailLayers() { .setFilter('trails-qa', ["all", showFixmesExpression, combinedFilterExpression]) .setFilter('trails-labels', combinedFilterExpression) .setFilter('trails-pointer-targets', combinedFilterExpression) - .setFilter('water-trail-pois', travelMode !== "canoe" ? [ - "any", - ["==", ["get", "waterway"], "waterfall"], - ] : null) + .setFilter('water-trail-pois', waterTrailPoisFilter(travelMode)) .setFilter('trail-pois', trailPoisFilter(travelMode)) .setFilter('major-trail-pois', [ "all",