import React from "react"; import { useMap } from "../MapComponent"; import AddRoundedIcon from "@mui/icons-material/AddRounded"; import RemoveRoundedIcon from "@mui/icons-material/RemoveRounded"; import FitScreenIcon from "@mui/icons-material/FitScreen"; import { config } from "@config/config"; const Zoom: React.FC = () => { const map = useMap(); // 放大函数 const handleZoomIn = () => { if (!map) return; const view = map.getView(); view.animate({ zoom: (view.getZoom() ?? 0) + 1, duration: 200 }); }; // 缩小函数 const handleZoomOut = () => { if (!map) return; const view = map.getView(); view.animate({ zoom: (view.getZoom() ?? 0) - 1, duration: 200 }); }; // 缩放到全局 Extent const handleFitScreen = () => { if (!map) return; const view = map.getView(); view.fit(config.MAP_EXTENT, { duration: 500 }); }; return (
); }; export default Zoom;