function markerInMapView() {
  // add polygon to map
  const mapBounds = map.getBounds();

  // check if map contains marker
  const contains = mapBounds.contains(marker.getLatLng());

  // add class to legend info about marker
  const markerInfo = document.querySelector(".checkMarker");
  markerInfo.textContent = contains;

  // change marker color
  markerInfo.classList[contains ? "remove" : "add"]("color-red");
}
Checking if the marker is in viewport