Skip to content

Commit 5690421

Browse files
committed
编辑增加状态
1 parent f05abdc commit 5690421

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

geojson-editor/src/App.vue

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import Measurer from './components/features/Measurer.vue';
1515
import FeatureCollectionEditor from './components/features/FeatureCollectionEditor.vue';
1616
import ShowEditorButton from './components/features/ShowEditorButton.vue';
1717
18-
import { DrawManager, GeoJSONLayerManager, MeasureManager , TIdentityGeoJSONFeature, MiddleButtonRoate} from '../../packages/maplugin-maplibre';
18+
import { DrawManager, GeoJSONLayerManager, MeasureManager, TIdentityGeoJSONFeature, MiddleButtonRoate, VertexEditor } from '../../packages/maplugin-maplibre';
1919
import { StoreEditor } from './stores';
2020
2121
import img_marker from './assets/map-marker.png?url';
@@ -47,6 +47,7 @@ function handleMapLoaded(map: maplibregl.Map) {
4747
});
4848
const drawManager = new DrawManager(glManager);
4949
const measureManager = new MeasureManager(glManager);
50+
const vertexEditor = new VertexEditor(map);
5051
5152
map.loadImage(img_marker).then((img) => {
5253
map.addImage("marker", img.data);
@@ -60,6 +61,19 @@ function handleMapLoaded(map: maplibregl.Map) {
6061
layout['icon-anchor'] = 'bottom';
6162
});
6263
64+
map.on('click', drawManager.id_layer_polygon, ({ features }) => {
65+
if (drawManager.drawing || !features || features.length === 0) return;
66+
const f = glManager.query((features[0].properties as any)['id']);
67+
if (f) {
68+
glManager.setFeatureHidden(f.properties.id);
69+
vertexEditor.setFeature(f, feature => {
70+
71+
glManager.clearFeatureHidden();
72+
glManager.update(feature);
73+
});
74+
}
75+
});
76+
6377
createMapControl(map, ShowEditorButton);
6478
createMapControl(map, Drawer, { drawManager }, 'top-left');
6579
createMapControl(map, Measurer, { measureManager }, 'top-left');

packages/maplugin-core/managers/geojson-draw-manager.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ export class DrawManager {
2626

2727
private escOnce: (e: KeyboardEvent) => void;
2828

29+
private _drawing = false;
30+
31+
get drawing(): boolean { return this._drawing; }
32+
2933
/**
3034
*
3135
*/
@@ -143,6 +147,7 @@ export class DrawManager {
143147

144148
start(mode: TDrawGeometryType) {
145149
this.stop();
150+
this._drawing = true;
146151
(this.glManager.map as any).doubleClickZoom.disable();
147152

148153
if (mode === 'Point')
@@ -172,6 +177,8 @@ export class DrawManager {
172177
this.stopFunc = undefined;
173178

174179
window.removeEventListener('keypress', this.escOnce);
180+
181+
this._drawing = false;
175182
}
176183

177184
clear(): void {

packages/maplugin-core/managers/geojson-layer-manager.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ export abstract class GeoJSONLayerManagerBase<TMap extends IMap = IMap, TFeature
162162
*/
163163
clearFeatureHidden(...id: string[]) {
164164
const fs = new Array<TFeature>();
165-
if (id.length === 0)
165+
166+
if (id.length !== 0)
166167
id.forEach(i => {
167168
const f = this.hiddenData.get(i);
168169
if (!f) return;

0 commit comments

Comments
 (0)