Skip to content

Commit 04edec6

Browse files
committed
update
1 parent f4dce99 commit 04edec6

File tree

6 files changed

+64
-39
lines changed

6 files changed

+64
-39
lines changed

geojson-editor/src/App.vue

Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@
88
</template>
99

1010
<script setup lang="ts">
11-
import { Component, createApp, h, ref, watch } from 'vue';
11+
import { ref, watch } from 'vue';
12+
import { createMapControl, createMapPopup } from './utils';
13+
1214
import Map from '../../packages/maplugin-maplibre/demo/Map.vue';
1315
import Measurer from './components/features/Measurer.vue';
1416
import FeatureCollectionEditor from './components/features/FeatureCollectionEditor.vue';
1517
import ShowEditorButton from './components/features/ShowEditorButton.vue';
1618
import Data from './components/features/Data/Data.vue';
19+
import ToggleButton from './components/base/ToggleButton.vue';
1720
1821
import { DrawManager, GeoJSONLayerManager, MeasureManager, TIdentityGeoJSONFeature, MiddleButtonRoate, VertexEditor, useCamera } from '../../packages/maplugin-maplibre';
1922
import { StoreEditor } from './stores';
@@ -93,19 +96,21 @@ function handleMapLoaded(map: maplibregl.Map) {
9396
drawManager.id_layer_line,
9497
drawManager.id_layer_line_circle,
9598
drawManager.id_layer_point,
96-
drawManager.id_layer_point_symbol], ({ features }) => {
99+
drawManager.id_layer_point_symbol], ({ features , lngLat}) => {
97100
if (drawManager.drawing || !features || features.length === 0) return;
98101
const f = glManager.query((features[0].properties as any)['id']);
99102
if (f) {
100-
glManager.setFeatureHidden(f.properties.id);
103+
// glManager.setFeatureHidden(f.properties.id);
104+
105+
// vertexEditor.setFeature(f, (id, g) => {
106+
// glManager.clearFeatureHidden(id);
101107
102-
vertexEditor.setFeature(f, (id, g) => {
103-
glManager.clearFeatureHidden(id);
108+
// const featrue = glManager.query(id)!;
109+
// featrue.geometry = g;
110+
// glManager.update(featrue);
111+
// });
104112
105-
const featrue = glManager.query(id)!;
106-
featrue.geometry = g;
107-
glManager.update(featrue);
108-
});
113+
createMapPopup(map, lngLat, ToggleButton, {content:"123", defaultActive: false});
109114
}
110115
});
111116
@@ -118,32 +123,7 @@ function handleMapLoaded(map: maplibregl.Map) {
118123
createMapControl(map, Measurer, { measureManager }, 'top-left');
119124
}
120125
121-
function createMapControl(map: maplibregl.Map, component: Component, data?: Record<string, unknown>, position: maplibregl.ControlPosition | "top-center" | "bottom-center" = 'top-right') {
122-
const div = document.createElement('div');
123-
div.classList.add("maplibregl-ctrl");
124-
createApp(component, data).mount(div);
125-
126-
if (position !== 'top-center' && position !== "bottom-center")
127-
map.addControl({
128-
onAdd() {
129-
return div;
130-
},
131-
onRemove() {
132-
div.remove();
133-
}
134-
}, position);
135-
136-
else{
137-
let container = document.querySelector(`.maplibregl-ctrl-${position}`);
138-
if(!container){
139-
container = document.createElement('div');
140-
container.classList.add(`maplibregl-ctrl-${position}`);
141-
map._controlContainer.append(container);
142-
}
143126
144-
container.append(div);
145-
}
146-
}
147127
</script>
148128

149129
<style scoped>

geojson-editor/src/components/features/Data/IO.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
<script setup lang="ts">
2323
import { TIdentityGeoJSONFeature } from '../../../../../packages/maplugin-core';
24-
import FileProcesses from '../../../services/file-processes';
24+
import { FileProcesses } from '../../../utils';
2525
2626
const props = defineProps<{
2727
onUpload(features: Array<TIdentityGeoJSONFeature>): void,

geojson-editor/src/services/file-processes.ts renamed to geojson-editor/src/utils/file-processes.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function appendId(fc: GeoJSON.FeatureCollection) {
1212
return fc;
1313
}
1414

15-
const FileProcesses: Array<{
15+
export const FileProcesses: Array<{
1616
extension: string,
1717
description: string,
1818
contentType: string
@@ -46,6 +46,4 @@ const FileProcesses: Array<{
4646
'compression': 'DEFLATE'
4747
})) as Blob;
4848
}
49-
}]
50-
51-
export default FileProcesses;
49+
}];

geojson-editor/src/utils/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './file-processes';
2+
export * from './map-ui';

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

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { Component, createApp } from "vue";
2+
3+
export function createMapControl(map: maplibregl.Map, component: Component, data?: Record<string, unknown>, position: maplibregl.ControlPosition | "top-center" | "bottom-center" = 'top-right') {
4+
const div = document.createElement('div');
5+
div.classList.add("maplibregl-ctrl");
6+
createApp(component, data).mount(div);
7+
8+
if (position !== 'top-center' && position !== "bottom-center")
9+
map.addControl({
10+
onAdd() {
11+
return div;
12+
},
13+
onRemove() {
14+
div.remove();
15+
}
16+
}, position);
17+
18+
else {
19+
let container = document.querySelector(`.maplibregl-ctrl-${position}`);
20+
if (!container) {
21+
container = document.createElement('div');
22+
container.classList.add(`maplibregl-ctrl-${position}`);
23+
map._controlContainer.append(container);
24+
}
25+
26+
container.append(div);
27+
}
28+
}
29+
30+
export function createMapPopup(map: maplibregl.Map, position: maplibregl.LngLatLike, component: Component, data?: Record<string, unknown>) {
31+
const div = document.createElement('div');
32+
div.classList.add("maplibregl-popup");
33+
createApp(component, data).mount(div);
34+
35+
// @ts-ignore
36+
const popup = new maplibregl.Popup()
37+
.setDOMContent(div)
38+
.setLngLat(position)
39+
.addTo(map);
40+
41+
return
42+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export class PopupManager{
2+
3+
}

0 commit comments

Comments
 (0)