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> = (props) => {
  const amapRef = useRef<Amap>();
  useEffect(() => {
    init();
    return () => amapRef.current?.destoryMap();
  }, []);
  const init = () => {
    amapRef.current = new Amap(PAGE_ID);
    const amap = amapRef.current;
  };
  return (
    <div className={styles.amap_container}>
      <div id={PAGE_ID} />
    </div>
  );
};

export default ThreeAmap;
