diff --git a/src/pages/main/MainPage.tsx b/src/pages/main/MainPage.tsx
index 36110138..0c7f24b4 100644
--- a/src/pages/main/MainPage.tsx
+++ b/src/pages/main/MainPage.tsx
@@ -1,4 +1,4 @@
-import { useState } from 'react';
+import { useEffect, useState } from 'react';
import AddIcon from '@/assets/icons/add.svg?react';
import AsyncBoundary from '@/components/async-boundary';
@@ -28,6 +28,20 @@ const MainPage = () => {
openModal();
};
+ useEffect(() => {
+ const handleMapContainerClick = (event: MouseEvent) => {
+ event.stopPropagation();
+ };
+
+ const mapContainer = mapContainerRef.current;
+
+ mapContainer?.addEventListener('click', handleMapContainerClick, true);
+
+ return () => {
+ mapContainer?.removeEventListener('click', handleMapContainerClick);
+ };
+ }, [mapContainerRef]);
+
return (
<>
diff --git a/src/utils/tmap/tmapModule.tsx b/src/utils/tmap/tmapModule.tsx
index 062443f0..596cebb9 100644
--- a/src/utils/tmap/tmapModule.tsx
+++ b/src/utils/tmap/tmapModule.tsx
@@ -25,9 +25,6 @@ export interface TmapConstructorType {
const { Tmapv3 } = window;
-const pathname = window.location.pathname;
-const isCoursePage = pathname.split('/')[1] === 'course';
-
export class TMapModule {
#mapInstance: typeof Tmapv3.Map;
#markers: MarkerType[] = [];
@@ -93,22 +90,19 @@ export class TMapModule {
});
};
- if (isCoursePage)
- (() => {
- this.#mapInstance.on('Click', handleMapClick);
+ this.#mapInstance.on('Click', handleMapClick);
- let throttleTimeout: NodeJS.Timeout | null = null;
- const THROTTLE_TIME = 800;
+ let throttleTimeout: NodeJS.Timeout | null = null;
+ const THROTTLE_TIME = 800;
- this.#mapInstance.on('Zoom', () => {
- if (!throttleTimeout) {
- throttleTimeout = setTimeout(() => {
- this.clusterMarkers();
- throttleTimeout = null;
- }, THROTTLE_TIME);
- }
- });
- })();
+ this.#mapInstance.on('Zoom', () => {
+ if (!throttleTimeout) {
+ throttleTimeout = setTimeout(() => {
+ this.clusterMarkers();
+ throttleTimeout = null;
+ }, THROTTLE_TIME);
+ }
+ });
}
// 마커 생성