@gis_victory/gismap 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/extensions.json +3 -0
- package/README.md +5 -0
- package/dist/gismap.css +1 -0
- package/dist/gismap.es.js +34794 -0
- package/dist/gismap.umd.js +2767 -0
- package/dist/index.d.ts +1 -0
- package/dist/vite.svg +1 -0
- package/index.html +13 -0
- package/package.json +32 -0
- package/public/vite.svg +1 -0
- package/src/App.vue +24 -0
- package/src/components/MapLayer/MCheckbox.vue +38 -0
- package/src/components/MapLayer/MapLayerApi.ts +97 -0
- package/src/components/MapLayer/index.vue +34 -0
- package/src/components/MapLegend/index.vue +20 -0
- package/src/components/MapTools/index.vue +20 -0
- package/src/components/MapView/index.vue +70 -0
- package/src/components/Widgets/MapCompass/index.vue +89 -0
- package/src/gismap.css +21 -0
- package/src/index.css +11 -0
- package/src/index.ts +7 -0
- package/src/main.ts +6 -0
- package/src/manager/EraserManager.ts +50 -0
- package/src/manager/IconManager.ts +40 -0
- package/src/manager/InitManager.ts +35 -0
- package/src/manager/LayerManager.ts +119 -0
- package/src/manager/MarkerManager.ts +65 -0
- package/src/manager/MaskManager.ts +37 -0
- package/src/manager/PopupManager.ts +46 -0
- package/src/manager/RadarManager.ts +156 -0
- package/src/manager/TDTManager.ts +149 -0
- package/src/manager/TemplateManager.ts +13 -0
- package/src/manager/TerrainManager.ts +61 -0
- package/src/manager/VectorManager.ts +51 -0
- package/src/manager/layer/Tile3DLayer.ts +114 -0
- package/src/style/gismap-layer.css +3 -0
- package/src/style/gismap-legend.css +3 -0
- package/src/style/gismap-maptools.css +3 -0
- package/src/style/mapbox-gl.css +1 -0
- package/src/types/GSMap.ts +25 -0
- package/src/utils/index.ts +22 -0
- package/src/utils/pubsub.ts +54 -0
- package/src/views/MapLayout.vue +28 -0
- package/src/vite-env.d.ts +1 -0
- package/tsconfig.app.json +15 -0
- package/tsconfig.json +7 -0
- package/tsconfig.node.json +25 -0
- package/vite.config.ts +35 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
package/dist/vite.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
package/index.html
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>Vite + Vue + TS</title>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<div id="app"></div>
|
|
11
|
+
<script type="module" src="/src/main.ts"></script>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@gis_victory/gismap",
|
|
3
|
+
"private": false,
|
|
4
|
+
"main": "dist/gismap.umd.js",
|
|
5
|
+
"module": "dist/gismap.es.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"style": "dist/gismap.css",
|
|
8
|
+
"version": "1.0.0",
|
|
9
|
+
"type": "module",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"dev": "vite",
|
|
12
|
+
"build": "vue-tsc -b && vite build",
|
|
13
|
+
"preview": "vite preview"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"vue": "^3.5.18",
|
|
17
|
+
"deck.gl": "^9.1.14",
|
|
18
|
+
"@deck.gl/geo-layers": "^9.1.14",
|
|
19
|
+
"@deck.gl/mapbox": "^9.1.14",
|
|
20
|
+
"@gis_victory/mapbox-gl": "^3.14.5",
|
|
21
|
+
"@turf/turf": "^7.2.0",
|
|
22
|
+
"wellknown": "^0.5.0"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@vitejs/plugin-vue": "^6.0.1",
|
|
26
|
+
"@vue/tsconfig": "^0.7.0",
|
|
27
|
+
"typescript": "~5.8.3",
|
|
28
|
+
"vite": "^7.1.2",
|
|
29
|
+
"vite-plugin-dts": "^4.5.4",
|
|
30
|
+
"vue-tsc": "^3.0.5"
|
|
31
|
+
}
|
|
32
|
+
}
|
package/public/vite.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
package/src/App.vue
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import MapLayout from './views/MapLayout.vue'
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<template>
|
|
6
|
+
<MapLayout />
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<style scoped>
|
|
10
|
+
.logo {
|
|
11
|
+
height: 6em;
|
|
12
|
+
padding: 1.5em;
|
|
13
|
+
will-change: filter;
|
|
14
|
+
transition: filter 300ms;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.logo:hover {
|
|
18
|
+
filter: drop-shadow(0 0 2em #646cffaa);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.logo.vue:hover {
|
|
22
|
+
filter: drop-shadow(0 0 2em #42b883aa);
|
|
23
|
+
}
|
|
24
|
+
</style>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="map-layer-group-item">
|
|
3
|
+
<el-checkbox v-model="checked" @change="onCheckedChange">
|
|
4
|
+
<div class="checked-content">
|
|
5
|
+
<span class="img"
|
|
6
|
+
><img :src="data?.icon" height="16" width="16"
|
|
7
|
+
/></span>
|
|
8
|
+
<span class="title">{{ data?.title }}</span>
|
|
9
|
+
</div>
|
|
10
|
+
</el-checkbox>
|
|
11
|
+
</div>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script lang="ts">
|
|
15
|
+
export default {
|
|
16
|
+
name: "MCheckbox",
|
|
17
|
+
}
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<script setup lang="ts">
|
|
21
|
+
import { onMounted, ref } from "vue";
|
|
22
|
+
|
|
23
|
+
const props = defineProps({
|
|
24
|
+
data: {
|
|
25
|
+
type: Object,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
const emit = defineEmits(["change"]);
|
|
29
|
+
const checked = ref(props.data?.checked);
|
|
30
|
+
|
|
31
|
+
const onCheckedChange = (val: boolean) => {
|
|
32
|
+
emit("change", val, props.data);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
onMounted(() => {
|
|
36
|
+
if (props.data?.checked) onCheckedChange(props.data?.checked);
|
|
37
|
+
});
|
|
38
|
+
</script>
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
export default class MapLayerApi {
|
|
2
|
+
private map: mapboxgl.Map;
|
|
3
|
+
private checkedParentLayers: Map<string, any> = new Map();
|
|
4
|
+
private checkedLayers: Map<string, any> = new Map();
|
|
5
|
+
public queryLayerIds: string[] = [];
|
|
6
|
+
constructor(map: mapboxgl.Map) {
|
|
7
|
+
this.map = map;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
private addSource(sourceConfig: any) {
|
|
11
|
+
if (!this.map.getSource(sourceConfig.id)) {
|
|
12
|
+
const source = Object.assign(
|
|
13
|
+
{
|
|
14
|
+
type: "geojson",
|
|
15
|
+
tiles: [sourceConfig.url],
|
|
16
|
+
},
|
|
17
|
+
sourceConfig
|
|
18
|
+
);
|
|
19
|
+
this.map.addSource(sourceConfig.id, source);
|
|
20
|
+
}
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
addLayer(layerConfig: any) {
|
|
25
|
+
this.addSource(layerConfig.source);
|
|
26
|
+
const layer = Object.assign(
|
|
27
|
+
{
|
|
28
|
+
id: layerConfig.id,
|
|
29
|
+
source: layerConfig.id,
|
|
30
|
+
},
|
|
31
|
+
layerConfig.layer
|
|
32
|
+
);
|
|
33
|
+
this.map.addLayer(layer);
|
|
34
|
+
this.checkedLayers.set(layer.id, {
|
|
35
|
+
layer,
|
|
36
|
+
extension: layerConfig?.extension,
|
|
37
|
+
});
|
|
38
|
+
if (layerConfig.isQuery) {
|
|
39
|
+
this.queryLayerIds.push(layer.id);
|
|
40
|
+
}
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
addGroupLayer(layer: any) {
|
|
45
|
+
const { id, layers } = layer;
|
|
46
|
+
if (layers) {
|
|
47
|
+
layers.forEach((_layer: any) => {
|
|
48
|
+
_layer.layer = Object.assign(
|
|
49
|
+
{
|
|
50
|
+
id: id,
|
|
51
|
+
source: id,
|
|
52
|
+
},
|
|
53
|
+
_layer.layer
|
|
54
|
+
);
|
|
55
|
+
_layer.source = Object.assign(
|
|
56
|
+
{
|
|
57
|
+
id: id,
|
|
58
|
+
},
|
|
59
|
+
_layer.source
|
|
60
|
+
);
|
|
61
|
+
this.addLayer(_layer);
|
|
62
|
+
});
|
|
63
|
+
this.checkedParentLayers.set(id, layer);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
removeLayer(layer: any) {
|
|
68
|
+
if (this.map.getLayer(layer.layer.id)) {
|
|
69
|
+
this.map.removeLayer(layer.layer.id);
|
|
70
|
+
}
|
|
71
|
+
// if (this.map.getSource(layer.source.id)) {
|
|
72
|
+
// this.map.removeSource(layer.source.id);
|
|
73
|
+
// }
|
|
74
|
+
this.checkedLayers.delete(layer.id);
|
|
75
|
+
if (layer.isQuery) {
|
|
76
|
+
this.queryLayerIds = this.queryLayerIds.filter(
|
|
77
|
+
(item) => item !== layer.layer.id
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
removeGroupLayer(layer: any) {
|
|
83
|
+
const { id, layers } = layer;
|
|
84
|
+
if (layers) {
|
|
85
|
+
layers.forEach((_layer: any) => {
|
|
86
|
+
_layer.layer = Object.assign({ id: id }, _layer.layer);
|
|
87
|
+
_layer.source = Object.assign({ id: id }, _layer.source);
|
|
88
|
+
this.removeLayer(_layer);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
this.checkedParentLayers.delete(id);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
getLayer(id: string) {
|
|
95
|
+
return id ? this.checkedLayers.get(id) : null;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="map-layer">
|
|
3
|
+
<div class="map-layer-box">
|
|
4
|
+
<div class="map-layer-group" v-for="(layer, index) in data" :key="index">
|
|
5
|
+
<div class="map-layer-group-title">{{ layer.title }}</div>
|
|
6
|
+
<div class="map-layer-group-content">
|
|
7
|
+
<div v-for="(item, index) in layer?.children || []" :key="index">
|
|
8
|
+
<MCheckbox :data="item" @change="onCheckedChange" />
|
|
9
|
+
</div>
|
|
10
|
+
</div>
|
|
11
|
+
</div>
|
|
12
|
+
</div>
|
|
13
|
+
</div>
|
|
14
|
+
</template>
|
|
15
|
+
<script setup lang="ts">
|
|
16
|
+
import { inject } from "vue";
|
|
17
|
+
import MCheckbox from "./MCheckbox.vue";
|
|
18
|
+
import type GSMap from "../../types/GSMap";
|
|
19
|
+
defineProps({
|
|
20
|
+
data: {
|
|
21
|
+
type: Array<any>,
|
|
22
|
+
default: () => [],
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
const map = inject<GSMap>("map");
|
|
26
|
+
|
|
27
|
+
const onCheckedChange = (val: any, layer: any) => {
|
|
28
|
+
if (val) {
|
|
29
|
+
map?.manager.layerManager.addGroupLayer(layer);
|
|
30
|
+
} else {
|
|
31
|
+
map?.manager.layerManager.removeGroupLayer(layer);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
</script>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script lang="ts">
|
|
6
|
+
export default {
|
|
7
|
+
name: "MapLegend",
|
|
8
|
+
}
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<script setup lang="ts">
|
|
12
|
+
// import type GSMap from "../../types/GSMap";
|
|
13
|
+
defineProps({
|
|
14
|
+
data: {
|
|
15
|
+
type: Array<any>,
|
|
16
|
+
default: () => [],
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
// const map = inject<GSMap>("map");
|
|
20
|
+
</script>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script lang="ts">
|
|
6
|
+
export default {
|
|
7
|
+
name: "MapTools",
|
|
8
|
+
}
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<script setup lang="ts">
|
|
12
|
+
// import type GSMap from "../../types/GSMap";
|
|
13
|
+
defineProps({
|
|
14
|
+
data: {
|
|
15
|
+
type: Array<any>,
|
|
16
|
+
default: () => [],
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
// const map = inject<GSMap>("map");
|
|
20
|
+
</script>
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div ref="mapContainer" class="gismap-container" />
|
|
3
|
+
<div class="gismap-control" v-if="isLoad">
|
|
4
|
+
<slot></slot>
|
|
5
|
+
</div>
|
|
6
|
+
</template>
|
|
7
|
+
<script lang="ts">
|
|
8
|
+
export default {
|
|
9
|
+
name: "MapView",
|
|
10
|
+
}
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<script setup lang="ts">
|
|
14
|
+
import { ref, onMounted, provide } from "vue";
|
|
15
|
+
import mapboxgl from "@gis_victory/mapbox-gl";
|
|
16
|
+
import MapInit from "../../manager/InitManager";
|
|
17
|
+
import GSMap from "../../types/GSMap";
|
|
18
|
+
const emit = defineEmits(["load"]);
|
|
19
|
+
const props = defineProps({
|
|
20
|
+
accessToken: {
|
|
21
|
+
type: String,
|
|
22
|
+
default: () => "",
|
|
23
|
+
},
|
|
24
|
+
tdtToken: {
|
|
25
|
+
type: String,
|
|
26
|
+
default: () => "",
|
|
27
|
+
},
|
|
28
|
+
options: {
|
|
29
|
+
type: Object,
|
|
30
|
+
default: () => ({}),
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
const isLoad = ref(false);
|
|
34
|
+
const mapContainer = ref<HTMLElement>();
|
|
35
|
+
|
|
36
|
+
onMounted(() => {
|
|
37
|
+
if (props.accessToken) {
|
|
38
|
+
mapboxgl.accessToken = props.accessToken;
|
|
39
|
+
}
|
|
40
|
+
const config: any = {
|
|
41
|
+
container: mapContainer.value!,
|
|
42
|
+
center: [120.65851, 29.5714],
|
|
43
|
+
minZoom: 8,
|
|
44
|
+
maxZoom: 20,
|
|
45
|
+
zoom: 15,
|
|
46
|
+
pitch: 65,
|
|
47
|
+
bearing: 0,
|
|
48
|
+
maxPitch: 85,
|
|
49
|
+
attributionControl: false,
|
|
50
|
+
spriteFormat: "auto",
|
|
51
|
+
...props.options,
|
|
52
|
+
};
|
|
53
|
+
if (!config.style) {
|
|
54
|
+
config.style = {
|
|
55
|
+
version: 8,
|
|
56
|
+
sources: {},
|
|
57
|
+
layers: [],
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const map = new GSMap(config);
|
|
62
|
+
|
|
63
|
+
map.on("load", () => {
|
|
64
|
+
map.manager = new MapInit(map, props.tdtToken);
|
|
65
|
+
isLoad.value = true;
|
|
66
|
+
emit("load", map);
|
|
67
|
+
});
|
|
68
|
+
provide("map", map);
|
|
69
|
+
});
|
|
70
|
+
</script>
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="map-compass" @click="handleClick">
|
|
3
|
+
<svg
|
|
4
|
+
class="compass"
|
|
5
|
+
:style="{
|
|
6
|
+
transformStyle: 'preserve-3d',
|
|
7
|
+
transform: `rotate(${-bearing}deg)`,
|
|
8
|
+
}"
|
|
9
|
+
viewBox="0 0 100 100"
|
|
10
|
+
>
|
|
11
|
+
<!-- 指南针外圈 -->
|
|
12
|
+
<circle
|
|
13
|
+
cx="50"
|
|
14
|
+
cy="50"
|
|
15
|
+
r="45"
|
|
16
|
+
fill="rgba(0, 0, 0, 0.01)"
|
|
17
|
+
stroke="#333"
|
|
18
|
+
stroke-width="3"
|
|
19
|
+
/>
|
|
20
|
+
<!-- 方向标记 -->
|
|
21
|
+
<text
|
|
22
|
+
x="50"
|
|
23
|
+
y="20"
|
|
24
|
+
text-anchor="middle"
|
|
25
|
+
font-size="12"
|
|
26
|
+
font-weight="bold"
|
|
27
|
+
>
|
|
28
|
+
N
|
|
29
|
+
</text>
|
|
30
|
+
<text
|
|
31
|
+
x="80"
|
|
32
|
+
y="50"
|
|
33
|
+
text-anchor="middle"
|
|
34
|
+
font-size="12"
|
|
35
|
+
font-weight="bold"
|
|
36
|
+
>
|
|
37
|
+
E
|
|
38
|
+
</text>
|
|
39
|
+
<text
|
|
40
|
+
x="50"
|
|
41
|
+
y="85"
|
|
42
|
+
text-anchor="middle"
|
|
43
|
+
font-size="12"
|
|
44
|
+
font-weight="bold"
|
|
45
|
+
>
|
|
46
|
+
S
|
|
47
|
+
</text>
|
|
48
|
+
<text
|
|
49
|
+
x="20"
|
|
50
|
+
y="50"
|
|
51
|
+
text-anchor="middle"
|
|
52
|
+
font-size="12"
|
|
53
|
+
font-weight="bold"
|
|
54
|
+
>
|
|
55
|
+
W
|
|
56
|
+
</text>
|
|
57
|
+
<!-- 指针 -->
|
|
58
|
+
<g class="needle">
|
|
59
|
+
<!-- 修改指针形状使其完全包含在圆内 -->
|
|
60
|
+
<polygon points="50,25 53,50 50,35 47,50" fill="#ff3333" />
|
|
61
|
+
<circle cx="50" cy="50" r="5" fill="#333" />
|
|
62
|
+
</g>
|
|
63
|
+
</svg>
|
|
64
|
+
</div>
|
|
65
|
+
</template>
|
|
66
|
+
|
|
67
|
+
<script setup lang="ts">
|
|
68
|
+
import GSMap from "../../../types/GSMap";
|
|
69
|
+
import { inject, onMounted, ref } from "vue";
|
|
70
|
+
const map = inject<GSMap>("map");
|
|
71
|
+
// 获取地图旋转角度
|
|
72
|
+
let bearing = ref(map?.getBearing() || 0);
|
|
73
|
+
let pitch = ref(map?.getPitch() || 0);
|
|
74
|
+
const handleClick = () => {
|
|
75
|
+
map?.resetNorthPitch();
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
onMounted(() => {
|
|
79
|
+
map?.on("rotate", (e) => {
|
|
80
|
+
bearing.value = e.target.getBearing();
|
|
81
|
+
});
|
|
82
|
+
map?.on("pitch", (e) => {
|
|
83
|
+
let _pitch = e.target.getPitch();
|
|
84
|
+
const correctedBearing =
|
|
85
|
+
e.target.getBearing() * Math.cos((_pitch * Math.PI) / 180);
|
|
86
|
+
pitch.value = correctedBearing;
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
</script>
|
package/src/gismap.css
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
@import url(./style/mapbox-gl.css);
|
|
2
|
+
@import url(./style/gismap-maptools.css);
|
|
3
|
+
@import url(./style/gismap-layer.css);
|
|
4
|
+
@import url(./style/gismap-legend.css);
|
|
5
|
+
.map-layout {
|
|
6
|
+
position: relative;
|
|
7
|
+
height: 100%;
|
|
8
|
+
width: 100%;
|
|
9
|
+
overflow: hidden;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.gismap-container {
|
|
13
|
+
height: 100%;
|
|
14
|
+
width: 100%;
|
|
15
|
+
background-color: #000;
|
|
16
|
+
overflow: hidden;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.mapboxgl-ctrl-logo {
|
|
20
|
+
display: none !important;
|
|
21
|
+
}
|
package/src/index.css
ADDED
package/src/index.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import './gismap.css';
|
|
2
|
+
import GisMapView from './components/MapView/index.vue';
|
|
3
|
+
import GisMapLayer from './components/MapLayer/index.vue';
|
|
4
|
+
import GisMapLegend from './components/MapLegend/index.vue';
|
|
5
|
+
import GisMapTools from './components/MapTools/index.vue';
|
|
6
|
+
|
|
7
|
+
export { GisMapView, GisMapLayer, GisMapLegend, GisMapTools };
|
package/src/main.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type GSMap from "../types/GSMap";
|
|
2
|
+
|
|
3
|
+
export default class EraserManager {
|
|
4
|
+
private map: GSMap;
|
|
5
|
+
private eraserLayerId: string = "eraser_layer";
|
|
6
|
+
private eraserDebugLayerId: string = "eraser_debug_layer";
|
|
7
|
+
constructor(map: GSMap) {
|
|
8
|
+
this.map = map;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
add(url: string, clipLayerTypes: any) {
|
|
12
|
+
this.map.addSource(this.eraserLayerId, {
|
|
13
|
+
type: "geojson",
|
|
14
|
+
data: url,
|
|
15
|
+
});
|
|
16
|
+
this.map.addLayer({
|
|
17
|
+
id: this.eraserLayerId,
|
|
18
|
+
source: this.eraserLayerId,
|
|
19
|
+
type: "clip",
|
|
20
|
+
layout: {
|
|
21
|
+
"clip-layer-types": clipLayerTypes,
|
|
22
|
+
"clip-layer-scope": ["basemap"],
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
remove() {
|
|
28
|
+
this.map.removeLayer(this.eraserLayerId);
|
|
29
|
+
this.map.removeSource(this.eraserLayerId);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
showPolygon() {
|
|
33
|
+
this.map.addLayer({
|
|
34
|
+
id: this.eraserDebugLayerId,
|
|
35
|
+
type: "line",
|
|
36
|
+
source: this.eraserLayerId,
|
|
37
|
+
paint: {
|
|
38
|
+
"line-color": "rgba(255, 0, 0, 0.9)",
|
|
39
|
+
"line-dasharray": [0, 4, 3],
|
|
40
|
+
"line-width": 5,
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
hidePolygon() {
|
|
46
|
+
if (this.map.getLayer(this.eraserDebugLayerId)) {
|
|
47
|
+
this.map.removeLayer(this.eraserDebugLayerId);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Map } from "@gis_victory/mapbox-gl";
|
|
2
|
+
export default class IconManager {
|
|
3
|
+
private map: Map;
|
|
4
|
+
constructor(map: Map) {
|
|
5
|
+
this.map = map;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
load(icons: any[]) {
|
|
9
|
+
let promises = [];
|
|
10
|
+
for (let icon of icons) {
|
|
11
|
+
promises.push(this._loadImage(icon));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return new Promise((resolve, reject) => {
|
|
15
|
+
Promise.all(promises)
|
|
16
|
+
.then((_) => {
|
|
17
|
+
resolve(true);
|
|
18
|
+
})
|
|
19
|
+
.catch((error) => {
|
|
20
|
+
reject(error);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
_loadImage(icon: any) {
|
|
26
|
+
return new Promise((resolve, reject) => {
|
|
27
|
+
this.map.loadImage(icon.url, (error, image: any) => {
|
|
28
|
+
if (error) {
|
|
29
|
+
reject(false);
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
32
|
+
if (this.map.hasImage(icon.name))
|
|
33
|
+
this.map.updateImage(icon.name, image);
|
|
34
|
+
else this.map.addImage(icon.name, image);
|
|
35
|
+
|
|
36
|
+
resolve(true);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import LayerManager from "./LayerManager";
|
|
2
|
+
import EraserManager from "./EraserManager";
|
|
3
|
+
import MaskManager from "./MaskManager";
|
|
4
|
+
import PopupManager from "./PopupManager";
|
|
5
|
+
import TDTManager from "./TDTManager";
|
|
6
|
+
import TerrainManager from "./TerrainManager";
|
|
7
|
+
import VectorManager from "./VectorManager";
|
|
8
|
+
import TemplateManager from "./TemplateManager";
|
|
9
|
+
import MarkerManager from "./MarkerManager";
|
|
10
|
+
|
|
11
|
+
export default class MapInit {
|
|
12
|
+
private map: mapboxgl.Map;
|
|
13
|
+
public layerManager: LayerManager;
|
|
14
|
+
public maskManager: MaskManager;
|
|
15
|
+
public tdtManager: TDTManager;
|
|
16
|
+
public eraserManager: EraserManager;
|
|
17
|
+
public popupManager: PopupManager;
|
|
18
|
+
public markerManager: MarkerManager;
|
|
19
|
+
public terrainManager: TerrainManager;
|
|
20
|
+
public vectorManager: VectorManager;
|
|
21
|
+
public templateManager: TemplateManager;
|
|
22
|
+
|
|
23
|
+
constructor(map: mapboxgl.Map, tdtToken?: string) {
|
|
24
|
+
this.map = map;
|
|
25
|
+
this.layerManager = new LayerManager(this.map);
|
|
26
|
+
this.maskManager = new MaskManager(this.map);
|
|
27
|
+
this.tdtManager = new TDTManager(this.map, tdtToken);
|
|
28
|
+
this.eraserManager = new EraserManager(this.map);
|
|
29
|
+
this.popupManager = new PopupManager(this.map);
|
|
30
|
+
this.markerManager = new MarkerManager(this.map);
|
|
31
|
+
this.terrainManager = new TerrainManager(this.map);
|
|
32
|
+
this.vectorManager = new VectorManager(this.map);
|
|
33
|
+
this.templateManager = new TemplateManager();
|
|
34
|
+
}
|
|
35
|
+
}
|