feature/业务线管理

feature/threejs
lys 3 months ago
parent 262b4f1ef7
commit 8010aeb09c

@ -13,14 +13,17 @@ const pluginsList = [
"AMap.PolyEditor", "AMap.PolyEditor",
"AMap.PolylineEditor" "AMap.PolylineEditor"
]; ];
export default class Amap { export default class AmapViewer {
public id: string; public id: string;
public center: number[];
public amapDom!: HTMLElement; public amapDom!: HTMLElement;
public map!: any; public map!: any;
public AMap!: any;
public normalMarker!: any; public normalMarker!: any;
constructor(id: string) { constructor(id: string, center: number[]) {
this.id = id; this.id = id;
this.center = center;
this.initAmap(); this.initAmap();
} }
@ -38,6 +41,7 @@ export default class Amap {
jsapi.src = url; jsapi.src = url;
document.head.appendChild(jsapi); document.head.appendChild(jsapi);
jsapi.onload = () => { jsapi.onload = () => {
console.log(1111, AMap)
this.initMap(); this.initMap();
}; };
jsapi.onerror = function () { jsapi.onerror = function () {
@ -51,7 +55,7 @@ export default class Amap {
this.amapDom = document.getElementById(this.id) as HTMLElement; this.amapDom = document.getElementById(this.id) as HTMLElement;
this.map = new AMap.Map(this.amapDom, { this.map = new AMap.Map(this.amapDom, {
zoom: 18, zoom: 18,
center: [118.794694, 32.434165], center: this.center,
resizeEnable: true, resizeEnable: true,
viewMode: "3D", viewMode: "3D",
defaultCursor: "default", defaultCursor: "default",

@ -1,21 +1,25 @@
import React, { useEffect, useRef } from "react"; import React, { useEffect, useRef } from "react";
import Amap from "@/lib/amap"; import AmapViewer from "@/lib/AmapViewer";
import ShadowMaterialAmap from "./modules/shadow";
import styles from "./index.less"; import styles from "./index.less";
interface OwnProps {} interface OwnProps {}
type Props = OwnProps; type Props = OwnProps;
const PAGE_ID = "DEMO_THREEAMAP"; const PAGE_ID = "DEMO_THREEAMAP",
CENTER = [118.794694, 32.434165];
const ThreeAmap: React.FC<Props> = (props) => { const ThreeAmap: React.FC<Props> = (props) => {
const amapRef = useRef<Amap>(); const amapRef = useRef<AmapViewer>();
useEffect(() => { useEffect(() => {
init(); init();
return () => amapRef.current?.destoryMap(); return () => amapRef.current?.destoryMap();
}, []); }, []);
const init = () => { const init = () => {
amapRef.current = new Amap(PAGE_ID); amapRef.current = new AmapViewer(PAGE_ID, CENTER);
const amap = amapRef.current; const amap = amapRef.current;
const shadowMaterialAmap = new ShadowMaterialAmap(amap);
shadowMaterialAmap.CreateGLlayer();
}; };
return ( return (
<div className={styles.amap_container}> <div className={styles.amap_container}>

@ -0,0 +1,24 @@
import type AmapViewer from "src/lib/AmapViewer";
export default class ShadowMaterialAmap {
protected Amap!: any;
constructor(map: AmapViewer) {
this.Amap = map;
}
// 创建 GL 图层
public CreateGLlayer() {
console.log("gllayer", this.Amap);
return;
const gllayer = new AMap.GLCustomLayer({
zIndex: 10, // 初始化的操作
init: (gl: any) => {
console.log("gl", gl);
},
render: () => {
console.log(123);
}
});
}
}
Loading…
Cancel
Save