Skip to content

Commit

Permalink
🐛 removeMarker에 배열에서 마커 삭제하는 로직 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
KimGaeun0806 committed Jan 21, 2024
1 parent e52446e commit 89d4c75
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/utils/tmap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class TMapModule {
}

this.#mapInstance = new Tmapv3.Map(mapId, {
center: new window.Tmapv3.LatLng(latitude, longitude),
center: new Tmapv3.LatLng(latitude, longitude),
width: `${width}px`,
height: `${height}px`,
zoom,
Expand Down Expand Up @@ -74,14 +74,15 @@ export class TMapModule {
latitude: number;
longitude: number;
}) {
const marker = this.#markers.find(
const targetMarkerIndex = this.#markers.findIndex(
(marker) =>
marker.getPosition().lat() === latitude &&
marker.getPosition().lng() === longitude,
);

if (!marker) return;
if (targetMarkerIndex === -1) return;

marker.setMap(null);
const targetMarker = this.#markers.splice(targetMarkerIndex, 1)[0];
targetMarker.setMap(null);
}
}

0 comments on commit 89d4c75

Please sign in to comment.