Skip to content

Commit

Permalink
Merge pull request #452 from boostcampwm-2024/frontend
Browse files Browse the repository at this point in the history
[FE][Feat] ์‚ฌ์šฉ์ž ๋งˆ์ปค ๋ฐ ํŒจ์Šค ์œ„๋กœ ์˜ฌ๋ฆผ, ๋ฐฉํ–ฅ ์ˆ˜์ •
  • Loading branch information
leedongyull authored Dec 5, 2024
2 parents 06262c8 + 5f3cd66 commit 8026973
Showing 1 changed file with 40 additions and 39 deletions.
79 changes: 40 additions & 39 deletions frontend/src/hooks/useRedraw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,45 @@ export const useRedrawCanvas = ({
clusteredMarkerSet.add(`${marker.lat.toFixed(6)}_${marker.lng.toFixed(6)}`),
);
});

const zoom = map.getZoom();

if (guests) {
guests.forEach(({ startPoint, endPoint, paths, markerStyle }) => {
const startLocationKey = `${startPoint.lat.toFixed(6)}_${startPoint.lng.toFixed(6)}`;
const endLocationKey = `${endPoint.lat.toFixed(6)}_${endPoint.lng.toFixed(6)}`;
if (!clusteredMarkerSet.has(startLocationKey)) {
const startLocation = latLngToCanvasPoint(startPoint);
drawMarker(
ctx,
startLocation,
startImageRef.current,
zoom,
0,
markerStyle.color,
MARKER_TYPE.START_MARKER,
);
}

if (!clusteredMarkerSet.has(endLocationKey)) {
const endLocation = latLngToCanvasPoint(endPoint);
drawMarker(
ctx,
endLocation,
endImageRef.current,
zoom,
0,
markerStyle.color,
MARKER_TYPE.END_MARKER,
);
}

// ๊ฒฝ๋กœ๋Š” ๋‘ ํฌ์ธํŠธ ์ค‘ ํ•˜๋‚˜๋ผ๋„ ํด๋Ÿฌ์Šคํ„ฐ์— ํฌํ•จ๋˜์ง€ ์•Š์œผ๋ฉด ๊ทธ๋ฆฌ๊ธฐ
if (!clusteredMarkerSet.has(startLocationKey) || !clusteredMarkerSet.has(endLocationKey)) {
drawPath(ctx, paths, markerStyle.color);
}
});
}

if (startMarker) {
const startPoint = latLngToCanvasPoint(startMarker);
const markerKey = `${startMarker.lat.toFixed(6)}_${startMarker.lng.toFixed(6)}`;
Expand Down Expand Up @@ -366,7 +403,7 @@ export const useRedrawCanvas = ({
const currentLocation = latLngToCanvasPoint({ lat, lng });
if (alpha) {
const normalizedAlpha = (alpha + 360) % 360;
const correctedAlpha = ((normalizedAlpha - 90 + 180) % 360) * (Math.PI / 180);
const correctedAlpha = ((90 - normalizedAlpha + 360) % 360) * (Math.PI / 180);
drawMarker(
ctx,
currentLocation,
Expand Down Expand Up @@ -396,7 +433,7 @@ export const useRedrawCanvas = ({
lng: location.lng ? location.lng : 0,
});
const normalizedAlpha = (location.alpha + 360) % 360;
const correctedAlpha = ((normalizedAlpha - 90 + 180) % 360) * (Math.PI / 180);
const correctedAlpha = ((90 - normalizedAlpha + 360) % 360) * (Math.PI / 180);

drawNeonCircleAndDirection(ctx, locationPoint, zoom, color);
drawMarker(
Expand All @@ -411,42 +448,6 @@ export const useRedrawCanvas = ({
});
}

if (guests) {
guests.forEach(({ startPoint, endPoint, paths, markerStyle }) => {
const startLocationKey = `${startPoint.lat.toFixed(6)}_${startPoint.lng.toFixed(6)}`;
const endLocationKey = `${endPoint.lat.toFixed(6)}_${endPoint.lng.toFixed(6)}`;
if (!clusteredMarkerSet.has(startLocationKey)) {
const startLocation = latLngToCanvasPoint(startPoint);
drawMarker(
ctx,
startLocation,
startImageRef.current,
zoom,
0,
markerStyle.color,
MARKER_TYPE.START_MARKER,
);
}

if (!clusteredMarkerSet.has(endLocationKey)) {
const endLocation = latLngToCanvasPoint(endPoint);
drawMarker(
ctx,
endLocation,
endImageRef.current,
zoom,
0,
markerStyle.color,
MARKER_TYPE.END_MARKER,
);
}

// ๊ฒฝ๋กœ๋Š” ๋‘ ํฌ์ธํŠธ ์ค‘ ํ•˜๋‚˜๋ผ๋„ ํด๋Ÿฌ์Šคํ„ฐ์— ํฌํ•จ๋˜์ง€ ์•Š์œผ๋ฉด ๊ทธ๋ฆฌ๊ธฐ
if (!clusteredMarkerSet.has(startLocationKey) || !clusteredMarkerSet.has(endLocationKey)) {
drawPath(ctx, paths, markerStyle.color);
}
});
}
if (clusters) {
clusters.forEach(cluster => {
drawCluster(ctx, cluster, startImageRef.current, zoom, cluster.color.color);
Expand Down

0 comments on commit 8026973

Please sign in to comment.