Make sure only visible layers are queried and react to visibility change