import React, { useEffect, useRef } from "react"; import Amap from "@/lib/amap"; import styles from "./index.less"; interface OwnProps {} type Props = OwnProps; const PAGE_ID = "DEMO_THREEAMAP"; const ThreeAmap: React.FC = (props) => { const amapRef = useRef(); useEffect(() => { init(); return () => amapRef.current?.destoryMap(); }, []); const init = () => { amapRef.current = new Amap(PAGE_ID); const amap = amapRef.current; }; return (
); }; export default ThreeAmap;