mirror of
https://github.com/pds-nest/nest.git
synced 2024-11-24 22:14:18 +00:00
24 lines
No EOL
568 B
JavaScript
24 lines
No EOL
568 B
JavaScript
import { useMemo, useState } from "react"
|
|
import Coordinates from "../objects/Coordinates"
|
|
import MapArea from "../objects/MapArea"
|
|
|
|
|
|
/**
|
|
* Hook which holds values required to create a {@link MapArea}.
|
|
*/
|
|
export default function useMapAreaState() {
|
|
const [zoom, setZoom] = useState(3)
|
|
const [center, setCenter] = useState(new Coordinates(0, 0))
|
|
const mapArea = useMemo(
|
|
() => MapArea.fromZoomLevel(zoom, center),
|
|
[zoom, center]
|
|
)
|
|
|
|
return {
|
|
zoom,
|
|
setZoom,
|
|
center,
|
|
setCenter,
|
|
mapArea,
|
|
}
|
|
} |