Skip to content

Commit

Permalink
DBC22-1258: click handler now check visible layers only
Browse files Browse the repository at this point in the history
  • Loading branch information
ray-oxd committed Nov 21, 2023
1 parent dbae6ce commit 2100d8d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/frontend/src/Components/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,8 @@ export default function MapWrapper({

mapRef.current.on('click', async (e) => {
// check if it was a webcam icon that was clicked
const camFeatures = await layers.current['webcamsLayer'].getFeatures(e.pixel);
const camFeatures = layers.current.webcamsLayer.getVisible() ?
await layers.current.webcamsLayer.getFeatures(e.pixel) : [];

if (camFeatures.length) {
const camData = camFeatures[0].getProperties();
Expand Down Expand Up @@ -405,7 +406,9 @@ export default function MapWrapper({
}
} else {
// if it wasn't a webcam icon, check if it was an event
const eventFeatures = await layers.current['eventsLayer'].getFeatures(e.pixel);
const eventFeatures = layers.current.eventsLayer.getVisible() ?
await layers.current.eventsLayer.getFeatures(e.pixel) : [];

if (eventFeatures.length) {
const feature = eventFeatures[0];

Expand Down

0 comments on commit 2100d8d

Please sign in to comment.