Skip to content

Commit 11f5e87

Browse files
committed
update
1 parent f045bc6 commit 11f5e87

File tree

4 files changed

+120
-17
lines changed

4 files changed

+120
-17
lines changed

geojson-editor/src/App.vue

Lines changed: 60 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import FeatureCollectionEditor from './components/features/FeatureCollectionEdit
1717
import ShowEditorButton from './components/features/ShowEditorButton.vue';
1818
import Data from './components/features/Data/Data.vue';
1919
import ToggleButton from './components/base/ToggleButton.vue';
20+
import DataDetail from './components/features/DataDetail.vue';
2021
2122
import { DrawManager, GeoJSONLayerManager, MeasureManager, TIdentityGeoJSONFeature, MiddleButtonRoate, VertexEditor, useCamera } from '../../packages/maplugin-maplibre';
2223
import { StoreEditor } from './stores';
@@ -68,7 +69,42 @@ function handleMapLoaded(map: maplibregl.Map) {
6869
// 中键旋转
6970
new MiddleButtonRoate(map);
7071
71-
const glManager = new GeoJSONLayerManager(map, new Array<TIdentityGeoJSONFeature>());
72+
const glManager = new GeoJSONLayerManager<TIdentityGeoJSONFeature>(map, [
73+
{
74+
"type": "Feature",
75+
"geometry": {
76+
"type": "Polygon",
77+
"coordinates": [
78+
[
79+
[
80+
121.20015593197513,
81+
31.646326873778108
82+
],
83+
[
84+
121.21262716876038,
85+
31.636886722815902
86+
],
87+
[
88+
121.22128404677903,
89+
31.644328677177043
90+
],
91+
[
92+
121.20797723212729,
93+
31.654153282119196
94+
],
95+
[
96+
121.20015593197513,
97+
31.646326873778108
98+
]
99+
]
100+
]
101+
},
102+
"properties": {
103+
"id": "09cd7939-9a47-4318-aeeb-64b8f2ed7ff4"
104+
}
105+
}
106+
]);
107+
72108
glManager.on('all', () => {
73109
fc.value = glManager.fc;
74110
});
@@ -96,21 +132,32 @@ function handleMapLoaded(map: maplibregl.Map) {
96132
drawManager.id_layer_line,
97133
drawManager.id_layer_line_circle,
98134
drawManager.id_layer_point,
99-
drawManager.id_layer_point_symbol], ({ features , lngLat}) => {
135+
drawManager.id_layer_point_symbol], ({ features, lngLat }) => {
100136
if (drawManager.drawing || !features || features.length === 0) return;
101137
const f = glManager.query((features[0].properties as any)['id']);
102138
if (f) {
103-
// glManager.setFeatureHidden(f.properties.id);
104-
105-
// vertexEditor.setFeature(f, (id, g) => {
106-
// glManager.clearFeatureHidden(id);
107-
108-
// const featrue = glManager.query(id)!;
109-
// featrue.geometry = g;
110-
// glManager.update(featrue);
111-
// });
112-
113-
createMapPopup(map, lngLat, ToggleButton, {content:"123", defaultActive: false});
139+
const popup = createMapPopup(map, lngLat, DataDetail, {
140+
featrue: f,
141+
onDelete() {
142+
glManager.delete(f);
143+
popup.remove();
144+
},
145+
onEdit() {
146+
glManager.setFeatureHidden(f.properties.id);
147+
148+
vertexEditor.setFeature(f, (id, g) => {
149+
glManager.clearFeatureHidden(id);
150+
151+
const featrue = glManager.query(id)!;
152+
featrue.geometry = g;
153+
glManager.update(featrue);
154+
});
155+
popup.remove();
156+
},
157+
onCopy() {
158+
popup.remove();
159+
}
160+
});
114161
}
115162
});
116163
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<template>
2+
<div class="detail">
3+
<div class="detail-data"></div>
4+
<div class="detail-action">
5+
<div class="detail-action-delete" @click="onDelete">删除</div>
6+
<div class="detail-action-edit" @click="onEdit">修改</div>
7+
<div class="detail-action-copy" @click="onCopy">复制</div>
8+
</div>
9+
</div>
10+
</template>
11+
12+
<script setup lang="ts">
13+
defineProps<{
14+
onDelete():void,
15+
onEdit():void
16+
onCopy():void,
17+
feature: GeoJSON.Feature
18+
}>();
19+
20+
21+
</script>
22+
23+
<style scoped>
24+
.detail {
25+
width: 200px;
26+
background-color: var(--color-bg);
27+
}
28+
29+
.detail-data {
30+
max-height: 300px;
31+
overflow-y: auto;
32+
}
33+
34+
.detail-action {
35+
display: flex;
36+
}
37+
38+
.detail-action>div {
39+
cursor: pointer;
40+
flex: 1;
41+
text-align: center;
42+
border: 1px solid #ccc;
43+
}
44+
45+
.detail-action>div:hover {
46+
background-color: var(--color-hover);
47+
}
48+
49+
.detail-action-delete {
50+
color: #f00;
51+
}
52+
</style>

geojson-editor/src/utils/map-ui.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Component, createApp } from "vue";
2+
import {Popup} from '../../../packages/maplugin-maplibre/demo/wapper';
23

34
export function createMapControl(map: maplibregl.Map, component: Component, data?: Record<string, unknown>, position: maplibregl.ControlPosition | "top-center" | "bottom-center" = 'top-right') {
45
const div = document.createElement('div');
@@ -29,14 +30,12 @@ export function createMapControl(map: maplibregl.Map, component: Component, data
2930

3031
export function createMapPopup(map: maplibregl.Map, position: maplibregl.LngLatLike, component: Component, data?: Record<string, unknown>) {
3132
const div = document.createElement('div');
32-
div.classList.add("maplibregl-popup");
3333
createApp(component, data).mount(div);
3434

35-
// @ts-ignore
36-
const popup = new maplibregl.Popup()
35+
const popup = new Popup({})
3736
.setDOMContent(div)
3837
.setLngLat(position)
3938
.addTo(map);
4039

41-
return
40+
return popup;
4241
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import {Popup} from 'maplibre-gl';
2+
3+
export {
4+
Popup
5+
};

0 commit comments

Comments
 (0)