Fixed marker

This commit is contained in:
PxlLoewe
2025-04-29 19:38:44 -07:00
parent 53e837cbc8
commit 8d41bdc938
3 changed files with 19 additions and 13 deletions

View File

@@ -26,6 +26,7 @@ export const calculateAnchor = (
mode: "popup" | "marker",
options?: { ignoreMarker?: boolean; ignoreCluster?: boolean },
) => {
console.log("calculateAnchor", id, mode, options);
const otherMarkers = document.querySelectorAll(".map-collision");
// get markers and check if they are overlapping
const ownMarker =
@@ -36,9 +37,9 @@ export const calculateAnchor = (
if (!otherMarkers || !ownMarker) return "topleft";
const marksersInCluster = Array.from(otherMarkers).filter((marker) => {
if (mode === "popup" && marker.id === `marker-${id}`) return false;
if (options?.ignoreMarker && marker.id.startsWith("marker")) return false;
if (options?.ignoreCluster && marker.id.startsWith("cluster")) return false;
if (mode === "popup" && marker.id === `marker-domain-${id}`) return false;
if (options?.ignoreMarker && marker.id.includes("marker")) return false;
if (options?.ignoreCluster && marker.id.includes("cluster")) return false;
const rect1 = (marker as HTMLElement).getBoundingClientRect();
const rect2 = (ownMarker as HTMLElement).getBoundingClientRect();
@@ -51,6 +52,8 @@ export const calculateAnchor = (
);
});
if (id.includes("13")) console.log(ownMarker, marksersInCluster);
// get the center of all overlapping markers
const markersPosition = marksersInCluster.map((marker) => {
const rect = (marker as HTMLElement).getBoundingClientRect();
@@ -102,9 +105,9 @@ export interface SmartPopupRef {
}
export const SmartPopup = (
props: PopupProps & {
options?: { ignoreMarker?: boolean; ignoreCluster?: boolean };
} & RefAttributes<LPopup> & {
props: PopupProps &
RefAttributes<LPopup> & {
options?: { ignoreMarker?: boolean; ignoreCluster?: boolean };
smartPopupRef?: Ref<SmartPopupRef>;
id: string;
wrapperClassName?: string;