基于高德地图JS api开发的geojson编辑器. http://geojson.finevis.cc/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
972 B

3 years ago
import "@amap/amap-jsapi-types";
import "../types";
import { IMapState } from "@store";
import { RectangleEditor } from "./editors";
3 years ago
export class MapEditor {
3 years ago
dom: HTMLDivElement;
private _map: AMap.Map | undefined;
private rectangleEditor: RectangleEditor | undefined;
3 years ago
constructor(dom: HTMLDivElement) {
this.dom = dom;
}
get map() {
return this._map!;
3 years ago
}
async init() {
await AMapLoader.load({
key: "a4171ad2d7df42823b4de7d25c8c35ee",
version: "2.0",
plugins: [
"AMap.RectangleEditor",
"AMap.PolylineEditor",
"AMap.PolygonEditor",
"AMap.PlaceSearch",
"AMap.AutoComplete",
],
});
this._map = new AMap.Map(this.dom);
this.initEditors();
}
update(state: IMapState) {
if (state.status === "createOverlay") {
this.rectangleEditor?.create();
}
}
initEditors() {
const { map } = this;
this.rectangleEditor = new RectangleEditor(map);
3 years ago
}
}