Skip to content

Commit 7d2462e

Browse files
committed
fix bug
1 parent 5e28cbb commit 7d2462e

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

packages/maplugin-core/managers/measure-manager.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ export class MeasureManager {
6464
constructor(dataSource: DrawManager | GeoJSONLayerManagerBase, options: MeasureOptions = {}) {
6565
this.glManager = dataSource instanceof DrawManager ? dataSource.glManager : dataSource;
6666

67+
// 清空自定义数据
68+
this.glManager.on('clear', () => this.customFeatures = []);
6769
this.glManager.on('all', () => this.renderMeasure());
6870

6971
this.glManager.addLayer(this.id_layer_measure_symbol);

packages/maplugin-maplibre/demo/Measure.vue

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
<input type="radio" :value="t" v-model="value">
1010
</div>
1111
<div>
12-
<button class="button" @click="measure.clear()">清除</button>
12+
<button class="button" @click="drawer.clear()">清除</button>
1313
</div>
1414
<div>
15-
<button class="button" @click="measure.stop()">停止</button>
15+
<button class="button" @click="drawer.stop()">停止</button>
1616
</div>
1717
</div>
1818

@@ -84,7 +84,7 @@
8484

8585
<script setup lang="ts">
8686
import Map from './Map.vue';
87-
import { GeoJSONLayerManager, MeasureManager, TDrawGeometryType, TIdentityGeoJSONFeature, Units } from '../index';
87+
import { DrawManager, GeoJSONLayerManager, MeasureManager, TDrawGeometryType, TIdentityGeoJSONFeature, Units } from '../index';
8888
import { ref, watch } from 'vue';
8989
9090
const value = ref("");
@@ -95,6 +95,7 @@ const radios = {
9595
}
9696
9797
let measure: MeasureManager;
98+
let drawer: DrawManager;
9899
const direction = ref(false);
99100
const distance = ref(false);
100101
const center = ref(false);
@@ -123,16 +124,16 @@ watch(precisions, a => {
123124
}, { deep: true });
124125
125126
function onMapLoad(map: maplibregl.Map) {
126-
const glManager = new GeoJSONLayerManager<TIdentityGeoJSONFeature>(map, []);
127-
measure = new MeasureManager(glManager, {});
127+
drawer = new DrawManager(new GeoJSONLayerManager<TIdentityGeoJSONFeature>(map, []));
128+
measure = new MeasureManager(drawer, {});
128129
measure.setDirectionSymbol(">>", "<<");
129130
measure.showPolygonDirection(false);
130131
measure.showPolygonDistance(false);
131132
measure.showSegment(false);
132133
}
133134
134135
function handleRadioClick(measureType: TDrawGeometryType) {
135-
measure.start(measureType);
136+
drawer.start(measureType);
136137
value.value = measureType;
137138
}
138139

0 commit comments

Comments
 (0)