Skip to content

Commit

Permalink
Add Google map location for bus stop
Browse files Browse the repository at this point in the history
  • Loading branch information
chunlaw committed Feb 27, 2024
1 parent 64f774c commit 5b5ef42
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/components/route-eta/StopDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
Bookmark as BookmarkIcon,
Close as CloseIcon,
Directions as DirectionsIcon,
MapOutlined as MapIcon,
} from "@mui/icons-material";
import {
Box,
Expand Down Expand Up @@ -54,6 +55,15 @@ const StopDialog = ({ open, stops, onClose }: StopDialogProps) => {
}
}, [stopList, stops]);

const handleClickLocation = useCallback(() => {
try {
const { lat, lng } = stopList[stops[0][1]]?.location;
window.open(`https://www.google.com/maps/?q=${lat},${lng}`, "_blank");
} catch (err) {
console.error(err);
}
}, [stopList, stops]);

return (
<Dialog open={open} onClose={onClose} sx={rootSx}>
<DialogTitle sx={titleSx}>
Expand All @@ -66,6 +76,9 @@ const StopDialog = ({ open, stops, onClose }: StopDialogProps) => {
<IconButton onClick={handleClickDirection}>
<DirectionsIcon />
</IconButton>
<IconButton onClick={handleClickLocation}>
<MapIcon />
</IconButton>
</Box>
<Box>
<IconButton onClick={onClose}>
Expand Down

0 comments on commit 5b5ef42

Please sign in to comment.