1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-22 21:14:18 +00:00
pds-2021-g2-nest/nest_frontend/hooks/useMapAreaState.js

21 lines
506 B
JavaScript
Raw Normal View History

2021-05-22 02:44:08 +00:00
import { 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 = MapArea.fromZoomLevel(zoom, center)
return {
zoom,
setZoom,
center,
setCenter,
mapArea,
}
}