Skip to content

Commit

Permalink
缺陷修改:支持s3m重复图层名添加,重复场景名提示
Browse files Browse the repository at this point in the history
  • Loading branch information
supermap123 committed May 8, 2024
1 parent ab24d47 commit 7a69092
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
type="text"
:placeholder="$t('layerName')"
:title="state.layerName"
:disabled="true"
:disabled="state.layerType != 'S3M'"
/>
</div>

Expand Down Expand Up @@ -180,7 +180,12 @@ function openLayer() {
switch (state.layerType) {
case "S3M":
addS3M(state.layerUrl);
let isExist = checkS3MLayeExist(state.layerName);
if (isExist) {
message.warning('图层名重复,请修改当前图层名称');
}else{
addS3M(state.layerUrl);
}
break;
case "Imagery":
addImage(state.layerUrl);
Expand All @@ -206,6 +211,10 @@ function handleChange() {
state.layerUrl,
"S3M"
);
let isExist = checkS3MLayeExist(state.layerName);
if(isExist){
message.warning('图层名重复,请修改当前图层名称');
}
}
break;
case "Imagery":
Expand Down Expand Up @@ -238,6 +247,15 @@ function handleChange() {
}
}
function checkS3MLayeExist(s3mLayerName:string){
let layerQueue = viewer.scene.layers.layerQueue;
let findIndex = layerQueue.findIndex((layer:any) => {
return layer.name == s3mLayerName;
})
return findIndex >= 0 ? true : false;
}
// 添加s3m
let promiseArray: any[] = [];
function addS3M(s3mLayerUrl: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@
<script lang="ts" setup>
import { reactive } from "vue";
import { useMessage } from "naive-ui";
import { GlobalStoreCreate } from "@/store/global/global";
const message = useMessage();
const GlobalStore = GlobalStoreCreate();
const state = reactive({
urlTip: "http://<server>:<port>/realspace/services/<component>/rest/realspace",
Expand All @@ -56,6 +58,22 @@ function handleChange(){
}
}
function checkSeneName(sceneUrl:string){
let url = sceneUrl+'/scenes.json';
window.axios.get(url).then((res: any) => {
let data = res.data;
if(data.length > 0){
let sceneName = data[0].name;
let isExist = GlobalStore.addSceneList.includes(sceneName);
if(isExist){
message.warning('该场景已存在,请勿重复添加');
}else{
GlobalStore.addSceneList.push(sceneName);
}
}
})
}
// 打开场景服务
function openScene() {
if (state.sceneUrl == null || state.sceneUrl == "") {
Expand All @@ -73,6 +91,11 @@ function openScene() {
);
}
// 不指定场景名称的情况下,检测当前场景是否已经添加过
if(state.sceneName == ''){
checkSeneName(state.sceneUrl);
}
let sceneName = state.sceneName == '' ? undefined : state.sceneName;
const promise = window.viewer.scene.open(state.sceneUrl, sceneName, { autoSetView: true });
SuperMap3D.when(promise, function (layers: any) {
Expand Down
3 changes: 2 additions & 1 deletion SuperMap iEarth/src/store/global/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ export interface GlobalStateType {
layerTreeCheckedKeys: any,
currentLanguage: string,
storageSceneCurrentTime: any
isNormalMode: boolean
isNormalMode: boolean,
addSceneList:string[]
}
1 change: 1 addition & 0 deletions SuperMap iEarth/src/store/global/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const GlobalStoreCreate = defineStore({
currentLanguage: '', // 当前语言
storageSceneCurrentTime: '', // 时间,这里先做一下保存,后面要改
isNormalMode: false,
addSceneList:[],
}),
actions: {}
});

0 comments on commit 7a69092

Please sign in to comment.