-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
956 additions
and
302 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React, {useEffect} from "react"; | ||
import {TooltipProvider} from "./components/ui/tooltip"; | ||
import {MapContainer} from "./map/map-container"; | ||
import {useAppStore} from "./store/store"; | ||
import {isValudGuid} from "./store/utils"; | ||
|
||
const AppContainer: React.FC = () => { | ||
const init = useAppStore((state) => state.initProject); | ||
useEffect(() => { | ||
const guid = location.pathname.split("/").pop(); | ||
init(isValudGuid(guid) ? guid : undefined); | ||
}, [init]); | ||
|
||
return ( | ||
<TooltipProvider> | ||
<MapContainer /> | ||
</TooltipProvider> | ||
); | ||
}; | ||
|
||
export default AppContainer; |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,38 @@ | ||
import React, {FC, useCallback} from "react"; | ||
import {LocateFixedIcon} from "lucide-react"; | ||
import {ToolbarButton} from "../components/toolbar-button"; | ||
import {INITIAL_MAP_VIEW_STATE, useAppStore} from "../store/store"; | ||
|
||
type Props = {}; | ||
|
||
const GeolocationContainer: FC<Props> = () => { | ||
const setMapViewState = useAppStore((state) => state.setMapViewState); | ||
|
||
const handleLocate = useCallback(() => { | ||
navigator.geolocation.getCurrentPosition( | ||
(position) => { | ||
const {latitude, longitude} = position.coords; | ||
setMapViewState({ | ||
...INITIAL_MAP_VIEW_STATE, | ||
latitude, | ||
longitude, | ||
zoom: 10, | ||
}); | ||
}, | ||
(error) => { | ||
console.error("error", error); | ||
} | ||
); | ||
}, [setMapViewState]); | ||
|
||
return ( | ||
<ToolbarButton | ||
isSelected={false} | ||
tooltipText={"Locate me"} | ||
icon={LocateFixedIcon} | ||
onClick={handleLocate} | ||
/> | ||
); | ||
}; | ||
|
||
export default GeolocationContainer; |
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,47 @@ | ||
import {LocateFixedIcon, SquareDotIcon} from "lucide-react"; | ||
import React, {FC} from "react"; | ||
import {MapRef} from "react-map-gl/maplibre"; | ||
import {ToolbarButton} from "../components/toolbar-button"; | ||
import ShareContainer from "./share-container"; | ||
import {ToolbarContainer} from "./toolbar-container"; | ||
import {UndoContainer} from "./undo-container"; | ||
import {useFitBounds} from "./use-fit-bounds"; | ||
import {useGeolocation} from "./use-geolocation"; | ||
|
||
type Props = { | ||
mapRef: React.RefObject<MapRef>; | ||
}; | ||
|
||
const MapControlsContainer: FC<Props> = (props) => { | ||
const {mapRef} = props; | ||
const {handleLocate} = useGeolocation(); | ||
const {handleFitBounds} = useFitBounds(mapRef); | ||
|
||
return ( | ||
<> | ||
<div className="absolute top-2 left-2"> | ||
<ToolbarContainer /> | ||
</div> | ||
<div className="absolute bottom-2 left-2"> | ||
<UndoContainer /> | ||
</div> | ||
<div className="absolute flex flex-col gap-1 top-2 right-2 items-end"> | ||
<ShareContainer /> | ||
<ToolbarButton | ||
isSelected={false} | ||
tooltipText={"Locate me"} | ||
icon={LocateFixedIcon} | ||
onClick={handleLocate} | ||
/> | ||
<ToolbarButton | ||
isSelected={false} | ||
tooltipText={"Fit bounds"} | ||
icon={SquareDotIcon} | ||
onClick={handleFitBounds} | ||
/> | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
export default MapControlsContainer; |
Oops, something went wrong.