Skip to content

Commit 361714b

Browse files
committed
更新点
1 parent a37079b commit 361714b

File tree

6 files changed

+14
-15
lines changed

6 files changed

+14
-15
lines changed

geojson-editor/src/App.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +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 } from '../../packages/maplugin-maplibre';
19-
import { TIdentityGeoJSONFeature } from '../../packages/maplugin-core/types';
18+
import { DrawManager, GeoJSONLayerManager, MeasureManager , TIdentityGeoJSONFeature, MiddleButtonRoate} from '../../packages/maplugin-maplibre';
2019
import { StoreEditor } from './stores';
2120
2221
import img_marker from './assets/map-marker.png?url';
@@ -26,8 +25,6 @@ const fc = ref<GeoJSON.FeatureCollection>({
2625
features: []
2726
});
2827
29-
let glManager: GeoJSONLayerManager;
30-
3128
function handleMapLoaded(map: maplibregl.Map) {
3229
map.setCenter([121, 31]);
3330
map.setZoom(8);
@@ -41,7 +38,10 @@ function handleMapLoaded(map: maplibregl.Map) {
4138
}
4239
});
4340
44-
glManager = new GeoJSONLayerManager(map, new Array<TIdentityGeoJSONFeature>());
41+
// 中键旋转
42+
new MiddleButtonRoate(map);
43+
44+
const glManager = new GeoJSONLayerManager(map, new Array<TIdentityGeoJSONFeature>());
4545
glManager.on('all', () => {
4646
fc.value = glManager.fc;
4747
});

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@ import { Tools } from "../utils/tools";
33

44
export type TFeatureEvent = "all" | "add" | "update" | "delete" | "clear" | "destory";
55

6-
export interface GeoJSONLayerManagerOptions<TFeature extends TIdentityGeoJSONFeature = TIdentityGeoJSONFeature> {
7-
map: IMap;
6+
export interface GeoJSONLayerManagerOptions<TMap extends IMap = IMap, TFeature extends TIdentityGeoJSONFeature = TIdentityGeoJSONFeature> {
7+
map: TMap;
88
data: Array<TFeature>;
99
}
1010

11-
export abstract class GeoJSONLayerManagerBase<TFeature extends TIdentityGeoJSONFeature = TIdentityGeoJSONFeature> {
11+
export abstract class GeoJSONLayerManagerBase<TMap extends IMap = IMap, TFeature extends TIdentityGeoJSONFeature = TIdentityGeoJSONFeature> {
1212
private events = new Map<string, Array<(e: { features?: TFeature[] }) => void>>();
1313
protected readonly layers = new Array<string>();
1414
protected data = new Map<string, TFeature>();
1515
protected hiddenData = new Map<string, TFeature>();
1616

17-
readonly map: IMap;
17+
readonly map: TMap;
1818
readonly source: string = Tools.uuid();
1919

2020
/**
@@ -27,7 +27,7 @@ export abstract class GeoJSONLayerManagerBase<TFeature extends TIdentityGeoJSONF
2727
} as Readonly<GeoJSON.FeatureCollection>;
2828
}
2929

30-
constructor(options: GeoJSONLayerManagerOptions<TFeature>) {
30+
constructor(options: GeoJSONLayerManagerOptions<TMap, TFeature>) {
3131
this.map = options.map;
3232
options.data.forEach(f => {
3333
this.data.set(f.properties.id, f);

packages/maplugin-core/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
export type TMapEvent = 'click' | 'dblclick' | 'mousemove' | 'contextmenu' | 'zoom' | 'style.load' | 'draw.selectionchange';
22

33
export interface IMap {
4-
dragRotate: number,
54
getContainer(): HTMLElement,
65

76
getStyle(): any;

packages/maplugin-core/utils/middle-button-roate.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,9 @@ export class MiddleButtonRoate {
244244

245245
const element = map.getContainer();
246246
this.map = map;
247-
this.mouseRotate = new MouseRotateHandler({ clickTolerance: (map.dragRotate as any)._mouseRotate._clickTolerance });
247+
this.mouseRotate = new MouseRotateHandler({ clickTolerance: ((map as any).dragRotate as any)._mouseRotate._clickTolerance });
248248
if (options.withPitch)
249-
this.mousePitch = new MousePitchHandler({ clickTolerance: (map.dragRotate as any)._mousePitch._clickTolerance });
249+
this.mousePitch = new MousePitchHandler({ clickTolerance: ((map as any).dragRotate as any)._mousePitch._clickTolerance });
250250

251251
const mousemove = (e: MouseEvent) => {
252252
this.move(e, DOM.mousePos(element, e));

packages/maplugin-mapbox/geojson-layer-manager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { GeoJSONLayerManagerBase, TFeatureEvent, TIdentityGeoJSONFeature } from '../maplugin-core';
22

33
export class GeoJSONLayerManager<TFeature extends TIdentityGeoJSONFeature = TIdentityGeoJSONFeature>
4-
extends GeoJSONLayerManagerBase<TFeature> {
4+
extends GeoJSONLayerManagerBase<mapboxgl.Map, TFeature> {
55

66
/**
77
*

packages/maplugin-maplibre/geojson-layer-manager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { GeoJSONLayerManagerBase, TFeatureEvent, TIdentityGeoJSONFeature } from '../maplugin-core';
22

33
export class GeoJSONLayerManager<TFeature extends TIdentityGeoJSONFeature = TIdentityGeoJSONFeature>
4-
extends GeoJSONLayerManagerBase<TFeature> {
4+
extends GeoJSONLayerManagerBase<maplibregl.Map, TFeature> {
55

66
/**
77
*

0 commit comments

Comments
 (0)