Disable clicking on buildings OpenStreetMap, Leaflet

Is there any way to disable the building area on the app using OpenStreetMap, Leaflet?
Thank you

map.on(“click”, debounce(function (e) {
const { lat, lng } = e.latlng;
console.log(Map clicked at: ${lat}, ${lng}); // Log click coordinates

getSurfaceType(lat, lng)
.then(data => {
console.log(“Surface Type API Response:”, data); // Log the response data

  // Proceed with getting the nearest road even if surface type data is null
  return getNearestRoad(lat, lng);
})
.then(nearestRoadData => {
  console.log('Nearest road data:', nearestRoadData); // Log the nearest road data
  if (nearestRoadData) {
    const nearestRoad = nearestRoadData.road;
    const adjustedLat = nearestRoadData.lat;
    const adjustedLng = nearestRoadData.lon;

    // Calculate the distance between the clicked point and the nearest road
    const distance = calculateDistance(lat, lng, adjustedLat, adjustedLng);
    console.log(`Distance to nearest road: ${distance} km`);

    if (distance <= DISTANCE_THRESHOLD) {
      // Show the modal immediately
      modal.style.display = "block";

      // Update the nearestHighwaySpan content asynchronously
      nearestHighwaySpan.textContent = `at "${nearestRoad}"`;

      // Get the modal input fields
      const nameInput = document.getElementById("name");
      const colorInput = document.getElementById("color");
      const startTimeInput = document.getElementById("startTime");
      const endTimeInput = document.getElementById("endTime");

      // Handle the "Create Node" button click
      const createNodeButton = document.getElementById("createNodeButton");

      createNodeButton.onclick = function () {
        const name = nameInput.value.trim();
        const nodeColor = colorInput.value.trim();
        const startTime = startTimeInput.value.trim();
        const endTime = endTimeInput.value.trim();

        if (!name) {
          customAlert("Please fill the stop name.");
          return;
        } else if ((startTime && !endTime)) {
          customAlert("Please fill the endTime or delete the startTime.");
          return;
        } else if ((endTime && !startTime)) {
          customAlert("Please fill the startTime or delete the endTime.");
          return;
        } else if (convertTimeToSeconds(startTime) > convertTimeToSeconds(endTime)) {
          customAlert("The startTime must be earlier than endTime.");
          return;
        }

        // Close the modal
        closeModal(modal);

        // Fetch additional data asynchronously
        fetch(`https://nominatim.openstreetmap.org/reverse?format=json&lat=${adjustedLat}&lon=${adjustedLng}&zoom=18&addressdetails=1`)
          .then(response => response.json())
          .then(data => {
            console.log('Nominatim response for adjusted coordinates:', data); // Log response for adjusted coordinates
            if (data && data.address) {
              const nearestHighway = data.address.road;
              const roadNumber = data.address.house_number || "";

              let icon;

              if (nodeColor === null) {
                icon = mapConfig.redIcon;
              } else if (nodeColor === "yellow") {
                icon = mapConfig.yellowIcon;
              } else if (nodeColor === "green") {
                icon = mapConfig.greenIcon;
              } else if (nodeColor === "orange") {
                icon = mapConfig.orangeIcon;
              } else if (nodeColor === "blue") {
                icon = mapConfig.blueIcon;
              } else if (nodeColor === "violet") {
                icon = mapConfig.violetIcon;
              } else {
                icon = mapConfig.redIcon;
              }

              checkIfmyNodeNameIsUnique(name).then(count => {
                if (count > 0) {
                  customAlert("This name is already taken. Please enter a different name.", 2);
                } else {
                  // Proceed with node creation here
                  const session = driver.session({ database: config.neo4jDatabase });
                  if (name) {
                    const storeNodeQuery = `
                      MERGE (n:Node {streetName: $streetName, latitude: $latitude, longitude: $longitude, streetNumber: $streetNumber, name: $nodeName ,nodeColor: $nodeColor ,startTime: $startTime , endTime: $endTime})
                    `;

                    session
                      .run(storeNodeQuery, { streetName: nearestHighway, latitude: adjustedLat, longitude: adjustedLng, streetNumber: roadNumber, nodeName: name, nodeColor: nodeColor, startTime: startTime, endTime: endTime })
                      .then(() => {
                        loadNodesFromNeo4j();
                        console.log("Node created in Neo4j with streetName:", nearestHighway, "latitude:", adjustedLat, "longitude:", adjustedLng, "streetNumber:", roadNumber, "name:", name, "nodeColor:", nodeColor, "startTime:", startTime, "endTime:", endTime);
                        L.marker([adjustedLat, adjustedLng], { icon: icon })
                          .addTo(map)
                          .bindPopup(`Street: ${nearestHighway}<br>Road Number: ${roadNumber}<br>Name: ${name}<br>Node Color: ${nodeColor}<br>Start Time: ${startTime}<br>End Time: ${endTime}<br><button onclick="removeMarker(this)">Cancel</button>`);
                      })
                      .catch((error) => {
                        console.error("Error creating node:", error);
                      })
                      .then(() => {
                        session.close();
                      });
                  } else {
                    customAlert("You have to give a name at the stop");
                  }
                }
              })
                .catch(error => {
                  console.error("Error:", error);
                });

            } else {
              customAlert("No address information found at this location. Node creation is not allowed.");
            }
          })
          .catch((error) => {
            console.error("Error fetching address data:", error);
          });
      };

      const closeButton = document.getElementsByClassName("close")[0];
      closeButton.onclick = function () {
        // Reset the input fields
        nameInput.value = "";
        colorInput.value = "";
        startTimeInput.value = "";
        endTimeInput.value = "";
        // Close the modal
        closeModal(modal);
      };

      // Function to close the modal
      function closeModal(modal) {
        modal.style.display = "none";
      }
    } else {
      customAlert("Stop creation is only allowed within 50 meters of a road.");
    }
  } else {
    customAlert("Stop creation is only allowed on roads.");
  }
})
.catch(error => {
  console.error("Error fetching nearest road:", error);
});

}, 300));

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật