Skip to content

Commit

Permalink
feat: TravelMapDetail 페이지 PolyLine 연결
Browse files Browse the repository at this point in the history
  • Loading branch information
dydals3440 committed Feb 17, 2024
1 parent 3cb21df commit e9fe3a3
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/components/map/TravelMapDetail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
GoogleMap,
InfoWindowF,
MarkerF,
Polyline,
useJsApiLoader,
} from '@react-google-maps/api';

Expand Down Expand Up @@ -62,6 +63,17 @@ const TravelMapDetail = ({ journeyInfo }) => {
setClicked(true);
};

const markerCoordinates = scheduleLocations
?.map(post => {
const latitude = parseFloat(post?.location?.latitude);
const longitude = parseFloat(post?.location?.longitude);
if (isNaN(latitude) || isNaN(longitude)) {
console.error('Invalid latitude or longitude:', post?.location);
return null;
}
return { lat: latitude, lng: longitude };
})
.filter(coordinate => coordinate !== null);
return isLoaded ? (
<GoogleMap
style={{ width: '1200', height: '450' }}
Expand Down Expand Up @@ -115,6 +127,15 @@ const TravelMapDetail = ({ journeyInfo }) => {
</S.InfoContainer>
</InfoWindowF>
)}
<Polyline
path={markerCoordinates}
geodesic={true}
options={{
strokeColor: '#F05650',
strokeOpacity: 0.6,
strokeWeight: 5,
}}
/>
</MarkerF>
))}
</GoogleMap>
Expand Down

0 comments on commit e9fe3a3

Please sign in to comment.