You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
601 B
TypeScript
28 lines
601 B
TypeScript
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;
|