From 2b3397878b3ba6faacc7e6f5b29a6cd0a1d7da19 Mon Sep 17 00:00:00 2001 From: ralex Date: Tue, 13 Feb 2018 12:22:41 -0600 Subject: [PATCH] Improved filtering of places shown on the map. Fixes #58 --- app/vientos-shell/vientos-shell.html | 2 +- app/vientos-shell/vientos-shell.js | 7 +++---- app/widgets/vientos-map/vientos-map.js | 2 +- src/util.js | 10 ++++++---- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/app/vientos-shell/vientos-shell.html b/app/vientos-shell/vientos-shell.html index 11defc0..453704d 100644 --- a/app/vientos-shell/vientos-shell.html +++ b/app/vientos-shell/vientos-shell.html @@ -228,7 +228,7 @@ util.inBoundingBox(place, boundingBox)) + return util.filterPlaces(places, boundingBox, visibleProjects, availableIntents) } _updateBoundingBox (e, detail) { diff --git a/app/widgets/vientos-map/vientos-map.js b/app/widgets/vientos-map/vientos-map.js index 1830341..4ea074f 100644 --- a/app/widgets/vientos-map/vientos-map.js +++ b/app/widgets/vientos-map/vientos-map.js @@ -54,7 +54,7 @@ class VientosMap extends Polymer.Element { _initializeMap ({ createMap, tileLayer, layerGroup, marker, icon, divIcon, toPoint }) { this.map = createMap(this.$.map) this.meIcon = divIcon({ - html: '
', + html: '
' }) this.map.setView([this.latitude, this.longitude], this.zoom) diff --git a/src/util.js b/src/util.js index 6fe2293..490e7e0 100644 --- a/src/util.js +++ b/src/util.js @@ -19,11 +19,13 @@ export function hasLocationsInBoundingBox (entity, places, boundingBox) { }) } -export function filterPlaces (entities, places, boundingBox) { +export function filterPlaces (places, boundingBox, projects, intents) { if (Array.from(arguments).includes(undefined)) return [] - return entities.reduce((acc, entity) => { - return acc.concat(hasLocationsInBoundingBox(entity, places, boundingBox)) - }, []) + let boundedPlaces = places.filter(place => inBoundingBox(place, boundingBox)) + return boundedPlaces.filter(place => { + return projects.some(project => project.locations.includes(place._id)) || + intents.some(intent => intent.locations.includes(place._id)) + }) } function appearsInSearchResults (entity, searchTerm, searchIndex) {