I have a map where some states are clickable, and some cities individually within those states are clickable. Each layer needs to open a different pop-up or overlay. Right now I'm using forEachFeatureAtPixel (I've tried forEachLayerAtPixel also). These obviously return each layer, so then my colorbox is duplicating in the instances where a pin or city feature is on top of a state feature.
When a pin is sitting on top of another layer, I'd like to only use the top layer instead of iterating through each feature. I'm having a hard time identifying the clicked layer, or top layer, in my logic. I'm not sure which method would be correct for this use case.