import HPaaSL7 from "../../../../hpaas-core/HPaaSL7"; import { ILayer, LineLayer, PointLayer, PolygonLayer, Popup } from "@antv/l7"; import { featureCollection, FeatureCollection, MultiPolygon, point, Polygon } from "@turf/turf"; import CORRender, { eventType } from "./IRender"; import { pointStyle, polygonStyle } from "../drawStyle"; class CORRenderL7 implements CORRender { private bgLayer?: ILayer[]; private pointsLayer?: ILayer[]; private hpaas: HPaaSL7; private _popup?: Popup; public inited = false; constructor(hpaas: HPaaSL7) { this.hpaas = hpaas; } initLayer() { this.inited = true; this.bgLayer = this.hpaas.scene.createLayer("Polygon", polygonStyle); this.hpaas.scene.addLayer(this.bgLayer); this.pointsLayer = this.hpaas.scene.createLayer("Point", pointStyle); this.hpaas.scene.addLayer(this.pointsLayer); } render( _featureCollection: FeatureCollection, pointsList: { lng: number; lat: number; }[] ) { this.bgLayer && this.hpaas.scene.setData(this.bgLayer, _featureCollection); const features = pointsList.map((d) => { return point([d.lng, d.lat]); }); this.pointsLayer && this.hpaas.scene.setData(this.pointsLayer, featureCollection(features)); } bindEvent(events: eventType) { this.hpaas.scene.sceneEvent.on("click", (e) => { events.click(e); }); this.hpaas.scene.sceneEvent.on("mousemove", (e) => { events.mousemove(e); }); } popup = { show: (html: string, pos: { lng: number; lat: number }) => { html && this.hpaas.scene.popup.html(html); this.hpaas.scene.popup.show(); }, hide: () => { this.hpaas.scene.popup.hide(); }, }; } export default CORRenderL7;