Skip to content

Commit 217ee97

Browse files
committed
update
1 parent f35c9dc commit 217ee97

File tree

10 files changed

+84
-6
lines changed

10 files changed

+84
-6
lines changed

geojson-editor/src/App.vue

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div class="container">
33
<Map class="map" :onMapLoad="handleMapLoaded"></Map>
4-
<div class="editor">
4+
<div class="editor" :class="{ hidden: !StoreEditor.show.value }">
55
<FeatureCollectionEditor :fc="fc"></FeatureCollectionEditor>
66
</div>
77
</div>
@@ -10,17 +10,20 @@
1010
<script setup lang="ts">
1111
import { Component, createApp, ref } from 'vue';
1212
import Map from '../../packages/maplugin-maplibre/demo/Map.vue';
13-
import Drawer from '../components/features/Drawer.vue';
14-
import Measurer from '../components/features/Measurer.vue';
15-
import FeatureCollectionEditor from '../components/features/FeatureCollectionEditor.vue';
13+
import Drawer from './components/features/Drawer.vue';
14+
import Measurer from './components/features/Measurer.vue';
15+
import FeatureCollectionEditor from './components/features/FeatureCollectionEditor.vue';
16+
import ShowEditorButton from './components/features/ShowEditorButton.vue';
1617
1718
import { DrawManager, GeoJSONLayerManager, MeasureManager } from '../../packages/maplugin-maplibre';
1819
import { TIdentityGeoJSONFeature } from '../../packages/maplugin-core/types';
20+
import { StoreEditor } from './stores';
1921
2022
const fc = ref<GeoJSON.FeatureCollection>({
2123
type: 'FeatureCollection',
2224
features: []
2325
});
26+
2427
let glManager: GeoJSONLayerManager;
2528
2629
function handleMapLoaded(map: maplibregl.Map) {
@@ -31,6 +34,7 @@ function handleMapLoaded(map: maplibregl.Map) {
3134
type: 'raster',
3235
source: {
3336
type: 'raster',
37+
maxzoom: 19,
3438
tiles: ["https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"]
3539
}
3640
});
@@ -40,6 +44,7 @@ function handleMapLoaded(map: maplibregl.Map) {
4044
fc.value = glManager.fc;
4145
});
4246
47+
createMapControl(map, ShowEditorButton);
4348
createMapControl(map, Drawer, { drawManager: new DrawManager(glManager, {}) });
4449
createMapControl(map, Measurer, { measureManager: new MeasureManager(glManager, {}) });
4550
}
@@ -77,4 +82,8 @@ function createMapControl(map: maplibregl.Map, component: Component, data?: Reco
7782
height: 100vh !important;
7883
width: 30%;
7984
}
85+
86+
.editor.hidden {
87+
display: none;
88+
}
8089
</style>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<template>
2+
<div class="toggle-button" :class="{ active: active }" @click="handleClick">{{ content }}</div>
3+
</template>
4+
5+
<script lang="ts" setup>
6+
import { ref } from 'vue';
7+
8+
const props = defineProps<{
9+
content: string,
10+
defaultActive: boolean,
11+
onChange: (val: boolean) => void
12+
}>();
13+
14+
const active = ref(props.defaultActive);
15+
16+
function handleClick(v: boolean) {
17+
props.onChange(!active.value);
18+
active.value = !active.value;
19+
}
20+
</script>
21+
22+
<style scoped>
23+
.toggle-button {
24+
padding: 6px 12px;
25+
background: var(--color-bg);
26+
color: var(--color-word);
27+
font-size: var(--color-word);
28+
cursor: pointer;
29+
border-radius: 6px;
30+
}
31+
32+
.toggle-button.active {
33+
color: var(--color-primary);
34+
}
35+
36+
.toggle-button:hover {
37+
background-color: var(--color-hover);
38+
}
39+
</style>

geojson-editor/components/features/Drawer.vue renamed to geojson-editor/src/components/features/Drawer.vue

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

99
<script lang="ts" setup>
1010
import RadioButton from '../base/RadioButton.vue';
11-
import { DrawManager, TDrawGeometryType } from '../../../packages/maplugin-core';
11+
import { DrawManager, TDrawGeometryType } from '../../../../packages/maplugin-core';
1212
import { ref, watch } from 'vue';
1313
1414
const radios: Record<TDrawGeometryType, string> = {

geojson-editor/components/features/Measurer.vue renamed to geojson-editor/src/components/features/Measurer.vue

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

1515
<script lang="ts" setup>
1616
import { ref, watch } from 'vue';
17-
import { MeasureManager } from '../../../packages/maplugin-core';
17+
import { MeasureManager } from '../../../../packages/maplugin-core';
1818
1919
const props = defineProps<{
2020
measureManager: MeasureManager
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<template>
2+
<ToggleButton content="编辑器" :defaultActive="StoreEditor.show.value" :onChange="v => StoreEditor.showEditor(v)">
3+
</ToggleButton>
4+
</template>
5+
6+
<script setup lang="ts">
7+
import ToggleButton from '../base/ToggleButton.vue';
8+
import { StoreEditor } from '../../stores/index';
9+
10+
</script>
11+
12+
<style scoped></style>

geojson-editor/src/stores/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './store-editor';
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { computed, ref } from "vue";
2+
3+
export namespace StoreEditor {
4+
const _show = ref(false);
5+
6+
export function toggle() {
7+
_show.value = !_show.value;
8+
}
9+
10+
export function showEditor(value: boolean) {
11+
_show.value = value;
12+
}
13+
14+
export const show = computed(() => {
15+
return _show.value;
16+
})
17+
}

0 commit comments

Comments
 (0)