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