-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop/fe' into feature/fe/#448
- Loading branch information
Showing
12 changed files
with
152 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
frontend/src/components/common/GoogleMapView/GoogleMapView.constant.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
export const GOOGLE_MAP_CONTAINER_STYLE = { | ||
width: "100%", | ||
height: "23rem", | ||
}; | ||
|
||
export const INIT_CENTER_POSITION = { | ||
lat: 37.5665, | ||
lng: 126.978, | ||
}; | ||
|
||
export const GOOGLE_MAP_OPTIONS = { | ||
disableDefaultUI: true, | ||
styles: [ | ||
{ | ||
featureType: "poi", | ||
elementType: "labels", | ||
stylers: [{ visibility: "off" }], | ||
}, | ||
], | ||
}; | ||
|
||
export const POLYLINE_OPTIONS = { strokeColor: "#72A2FFCC", strokeWeight: 3 }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
frontend/src/components/common/GoogleMapView/GoogleMapView.util.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { INIT_CENTER_POSITION } from "@components/common/GoogleMapView/GoogleMapView.constant"; | ||
|
||
import theme from "@styles/theme"; | ||
|
||
export const calculateCenter = ( | ||
places: { lat: number; lng: number }[], | ||
): { lat: number; lng: number } => { | ||
if (places.length === 0) { | ||
return { lat: INIT_CENTER_POSITION.lat, lng: INIT_CENTER_POSITION.lng }; | ||
} | ||
const latSum = places.reduce((sum, place) => sum + place.lat, 0); | ||
const lngSum = places.reduce((sum, place) => sum + place.lng, 0); | ||
const count = places.length; | ||
|
||
return { | ||
lat: latSum / count, | ||
lng: lngSum / count, | ||
}; | ||
}; | ||
|
||
export const createMarkerLabelStyle = (markerOrder: number) => { | ||
return { | ||
text: `${markerOrder + 1}`, | ||
color: theme.colors.primary, | ||
fontSize: "1.4rem", | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { useCallback, useState } from "react"; | ||
|
||
import { MapPosition } from "@type/domain/common"; | ||
|
||
const INIT_CENTER_POSITION = { | ||
lat: 37.5665, | ||
lng: 126.978, | ||
}; | ||
|
||
const useGoogleMap = (places: MapPosition[]) => { | ||
const [googleMap, setGoogleMap] = useState<google.maps.Map | null>(null); | ||
|
||
const onLoad = useCallback((map: google.maps.Map) => { | ||
setGoogleMap(map); | ||
}, []); | ||
|
||
const onUnmount = useCallback(() => { | ||
setGoogleMap(null); | ||
}, []); | ||
|
||
const onBoundsChanged = useCallback(() => { | ||
if (googleMap) { | ||
if (places.length === 0) { | ||
googleMap.setCenter(INIT_CENTER_POSITION); | ||
googleMap.setZoom(7); | ||
} else { | ||
const bounds = new window.google.maps.LatLngBounds(); | ||
places.forEach((place) => { | ||
bounds.extend(new window.google.maps.LatLng(place.lat, place.lng)); | ||
}); | ||
googleMap.fitBounds(bounds); | ||
} | ||
} | ||
}, [places, googleMap]); | ||
|
||
return { | ||
onLoad, | ||
onUnmount, | ||
onBoundsChanged, | ||
}; | ||
}; | ||
|
||
export default useGoogleMap; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters