|
|
|
@ -1,7 +1,7 @@
|
|
|
|
|
import { IMapEditor } from "@map"; |
|
|
|
|
import { Action } from "redux"; |
|
|
|
|
import { Modal } from "antd"; |
|
|
|
|
import { registerHotkey, downloadJSON } from "@utils"; |
|
|
|
|
import { registerHotkey, downloadJSON, openUpload } from "@utils"; |
|
|
|
|
|
|
|
|
|
import { getGeoJSON } from "../utils"; |
|
|
|
|
import { OverlayTypes, EventTypes } from "@types"; |
|
|
|
@ -49,16 +49,7 @@ export class EditorAction {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
setInterval(() => { |
|
|
|
|
const { mapOptions } = this; |
|
|
|
|
sessionStorage.setItem( |
|
|
|
|
"fine-geojson", |
|
|
|
|
JSON.stringify({ |
|
|
|
|
...mapOptions, |
|
|
|
|
center: this.mapEditor?.getCenter(), |
|
|
|
|
zoom: this.mapEditor?.getZoom(), |
|
|
|
|
}) |
|
|
|
|
); |
|
|
|
|
console.log("saved!"); |
|
|
|
|
this.saveTemp(); |
|
|
|
|
}, 10000); |
|
|
|
|
} |
|
|
|
|
// ---------- public methods -------------
|
|
|
|
@ -92,11 +83,6 @@ export class EditorAction {
|
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
saveGeoJSON() { |
|
|
|
|
const geojson = getGeoJSON(this.mapOptions); |
|
|
|
|
downloadJSON(geojson, "fine.geojson"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
selectOverlay(id: string) { |
|
|
|
|
const { selectedIds } = this.store.getState(); |
|
|
|
|
if (selectedIds.indexOf(id) >= 0) { |
|
|
|
@ -108,12 +94,24 @@ export class EditorAction {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
saveGeoJSON() { |
|
|
|
|
const geojson = getGeoJSON(this.mapOptions); |
|
|
|
|
downloadJSON(geojson, "fine.geojson"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
saveProject() { |
|
|
|
|
//
|
|
|
|
|
const mapOptions = this._getMapOptions(); |
|
|
|
|
downloadJSON(mapOptions, "fine.fjd"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
saveTemp() { |
|
|
|
|
//
|
|
|
|
|
sessionStorage.setItem( |
|
|
|
|
"fine-geojson", |
|
|
|
|
JSON.stringify(this._getMapOptions()) |
|
|
|
|
); |
|
|
|
|
console.log("saved!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
clearOverlays() { |
|
|
|
|
Modal.confirm({ |
|
|
|
|
title: "确定移除所有覆盖物吗?", |
|
|
|
@ -124,16 +122,30 @@ export class EditorAction {
|
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
openGeoJSON() { |
|
|
|
|
//
|
|
|
|
|
openUpload({ |
|
|
|
|
accept: ".geojson", |
|
|
|
|
onReady: (content) => { |
|
|
|
|
this._openGeoJSON(JSON.parse(content)); |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
openProject() { |
|
|
|
|
//
|
|
|
|
|
openUpload({ |
|
|
|
|
accept: ".fjd", |
|
|
|
|
onReady: (content) => { |
|
|
|
|
this._openProject(JSON.parse(content)); |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
showCommand() { |
|
|
|
|
//
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private _openGeoJSON(geojson: GeoJSON.FeatureCollection) { |
|
|
|
|
console.log(geojson); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private _openProject(options: IMapOptions) { |
|
|
|
|
this.mapEditor?.importProject(options); |
|
|
|
|
this.dispatch( |
|
|
|
@ -144,8 +156,20 @@ export class EditorAction {
|
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private _getMapOptions(): IMapOptions { |
|
|
|
|
const { mapOptions } = this; |
|
|
|
|
return { |
|
|
|
|
...mapOptions, |
|
|
|
|
center: this.mapEditor?.getCenter(), |
|
|
|
|
zoom: this.mapEditor?.getZoom(), |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private _bindActions() { |
|
|
|
|
this.saveGeoJSON = this.saveGeoJSON.bind(this); |
|
|
|
|
this.saveProject = this.saveProject.bind(this); |
|
|
|
|
this.openGeoJSON = this.openGeoJSON.bind(this); |
|
|
|
|
this.openProject = this.openProject.bind(this); |
|
|
|
|
this.createRectangle = this.createRectangle.bind(this); |
|
|
|
|
this.createPolygon = this.createPolygon.bind(this); |
|
|
|
|
this.createPolyline = this.createPolyline.bind(this); |
|
|
|
|