Browse Source
Attaching filter rules to markers appearing/disappearing on map
Attaching filter rules to markers appearing/disappearing on map
Strategy: Remove all markers before attaching new ones (already selected the ones the user wants to see)master
GabrielTrettel
3 years ago
4 changed files with 69 additions and 77 deletions
-
49src/app/components/MapMarkerList.js
-
24src/app/components/map/LeafLetMap.js
-
54src/app/components/map/OpenStreetMap.js
-
3src/app/hooks/selectFromDB.js
@ -1,45 +1,20 @@ |
|||||
import useMarkers from "../hooks/selectFromDB"; |
|
||||
|
|
||||
function isRequestedValue( |
|
||||
item, |
|
||||
renderRain, |
|
||||
renderFlood, |
|
||||
renderRiver, |
|
||||
renderPluviometer, |
|
||||
renderOfficialPluviometer |
|
||||
) { |
|
||||
|
function isRequestedValue(item, renderOptions) { |
||||
return ( |
return ( |
||||
(item.name == "pluviometer" && renderPluviometer) || |
|
||||
(item.name == "officialPluviometer") & renderOfficialPluviometer || |
|
||||
(item.name == "rain" && renderRain) || |
|
||||
(item.name == "river" && renderRiver) || |
|
||||
(item.name == "flood" && renderFlood) |
|
||||
|
(item.name == "pluviometer" && renderOptions.citzen.pluviometer) || |
||||
|
(item.name == "officialPluviometer" && |
||||
|
renderOptions.oficial.automaticPluviometer) || |
||||
|
(item.name == "rain" && renderOptions.citzen.rain) || |
||||
|
(item.name == "river" && renderOptions.citzen.riverFlood) || |
||||
|
(item.name == "flood" && renderOptions.citzen.floodRisk) |
||||
); |
); |
||||
} |
} |
||||
|
|
||||
function MapMarkerList({ |
|
||||
markers, |
|
||||
renderRain = true, |
|
||||
renderFlood = true, |
|
||||
renderRiver = true, |
|
||||
renderPluviometer = true, |
|
||||
renderOfficialPluviometer = true, |
|
||||
}) { |
|
||||
|
|
||||
// FIXME: Resolve this later!!!
|
|
||||
return markers.markers; |
|
||||
|
function MapMarkerList({ markers, renderOptions }) { |
||||
|
if (!markers) return null; |
||||
|
|
||||
// return [...markers.markers].filter(([k, item]) => {
|
|
||||
// isRequestedValue(
|
|
||||
// item,
|
|
||||
// renderRain,
|
|
||||
// renderFlood,
|
|
||||
// renderRiver,
|
|
||||
// renderPluviometer,
|
|
||||
// renderOfficialPluviometer
|
|
||||
// )
|
|
||||
// }
|
|
||||
// );
|
|
||||
|
return [...markers.markers].filter(([_, item]) => { |
||||
|
return isRequestedValue(item, renderOptions); |
||||
|
}); |
||||
} |
} |
||||
|
|
||||
export { MapMarkerList }; |
export { MapMarkerList }; |
Write
Preview
Loading…
Cancel
Save
Reference in new issue