Skip to content

Commit

Permalink
缺陷修改:支持多场景服务下指定场景名称打开
Browse files Browse the repository at this point in the history
  • Loading branch information
supermap123 committed Apr 22, 2024
1 parent f3040d5 commit b6c0ec6
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 68 deletions.
4 changes: 3 additions & 1 deletion SuperMap iEarth/public/locale/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,9 @@ const local_en = {
qxLayerDataUrl: 'Please enter the data service URL for this layer',
qxLayerDataSource: 'Please enter the data source corresponding to this layer',
qxLayerDataset: 'Please enter the data set corresponding to this layer',
education: "SuperMap Education"
education: "SuperMap Education",
urlChecedFail:"Url verification failed, please enter the correct address",
appointSceneName:'Specify scene name',
}

window.local_en = local_en;
4 changes: 3 additions & 1 deletion SuperMap iEarth/public/locale/ja.js
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,9 @@ const local_ja = {
qxLayerDataUrl: 'このレイヤーのデータ サービス URL を入力してください',
qxLayerDataSource: 'このレイヤーに対応するデータ ソースを入力してください',
qxLayerDataset: 'このレイヤーに対応するデータセットを入力してください',
education: "教育版"
education: "教育版",
urlChecedFail:"Urlチェックに失敗しました。正しいアドレスを入力してください",
appointSceneName:'シーン名の指定',
}

window.local_ja = local_ja;
4 changes: 3 additions & 1 deletion SuperMap iEarth/public/locale/ru.js
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,9 @@ const local_ru = {
qxLayerDataUrl: 'Введите URL-адрес службы данных для этого слоя.',
qxLayerDataSource: 'Пожалуйста, введите источник данных, соответствующий этому слою',
qxLayerDataset: 'Пожалуйста, введите набор данных, соответствующий этому слою',
education: "обучать"
education: "обучать",
urlChecedFail:"Ошибка проверки Url, введите правильный адрес",
appointSceneName:'Укажите имя сцены',
}

window.local_ru = local_ru;
4 changes: 3 additions & 1 deletion SuperMap iEarth/public/locale/zh.js
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,9 @@ const local_zh = {
qxLayerDataUrl: '请输入该图层的数据服务URL',
qxLayerDataSource: '请输入该图层对应的数据源',
qxLayerDataset: '请输入该图层对应的数据集',
education: "教育版"
education: "教育版",
urlChecedFail:"Url校验失败,请输入正确地址",
appointSceneName:'指定场景名称',
}

window.local_zh = local_zh;
112 changes: 49 additions & 63 deletions SuperMap iEarth/src/package/addData/layer-custom/components/scene.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,106 +3,92 @@
<span>{{ $t("address") }}</span>
<n-tooltip placement="top-end" trigger="hover">
<template #trigger>
<n-input
class="add-input-border"
v-model:value="sceneUrl"
type="text"
style="width: 2.4rem"
:title="sceneUrl"
@input="handleChange"
/>
<n-input class="add-input-border" v-model:value="state.sceneUrl" type="text" style="width: 2.4rem"
:title="state.sceneUrl" @change="handleChange"/>
</template>
{{ urlTip }}
{{ state.urlTip }}
</n-tooltip>
</div>

<div style="margin-left: 0.95rem; margin-bottom: 0.1rem">
<n-checkbox v-model:checked="token"> {{ $t("addToken") }} </n-checkbox>
<n-input
style="margin-top: 0.1rem; width: 2.4rem"
v-if="token"
v-model:value="sceneToken"
type="text"
placeholder="token..."
/>
<n-checkbox v-model:checked="state.useSenceName">{{ $t("appointSceneName") }}</n-checkbox>
</div>

<div class="row-item" v-if="state.useSenceName">
<span>{{ $t("name") }}</span>
<n-input class="add-input-border" v-model:value="state.sceneName" type="text" style="width: 2.4rem"/>
</div>

<div style="margin-left: 0.95rem; margin-bottom: 0.1rem">
<n-checkbox v-model:checked="state.token"> {{ $t("addToken") }} </n-checkbox>
<n-input style="margin-top: 0.1rem; width: 2.4rem" v-if="state.token" v-model:value="state.sceneToken" type="text"
placeholder="token..." />
</div>

<div class="btn-row-item" style="margin-left: 0.95rem">
<n-button
type="info"
color="#3499E5"
text-color="#fff"
class="ans-btn"
@click="openScene"
>{{ $t("sure") }}</n-button
>
<n-button
class="btn-secondary"
@click="clear"
color="rgba(255, 255, 255, 0.65)"
ghost
>{{ $t("clear") }}</n-button
>
<n-button type="info" class="ans-btn" color="#3499E5" text-color="#fff" :focusable="false" @click="openScene">{{
$t("sure") }}</n-button>
<n-button :focusable="false" @click="clear">{{ $t("clear") }}</n-button>
</div>
</template>

<script lang="ts" setup>
import { ref } from "vue";
import { reactive } from "vue";
import { useMessage } from "naive-ui";
import layerManagement from "@/tools/layerManagement";
const message = useMessage();
let urlTip =
"http://<server>:<port>/realspace/services/<component>/rest/realspace";
let sceneUrl = ref("");
let sceneToken = ref("");
let token = ref(false);
const state = reactive({
urlTip: "http://<server>:<port>/realspace/services/<component>/rest/realspace",
sceneUrl: '',
sceneName: '',
sceneToken: '',
token: false,
useSenceName:false
})
// 校验URL
function handleChange() {
// 检查地址是否正确 - 使用正则严格校验
if (sceneUrl.value.indexOf("rest/realspace") != -1) {
message.success($t("urlCheckedsuccess"));
//检查场景服务地址是否合规
let reg = /rest\/realspace$/g;
function handleChange(){
state.sceneUrl = state.sceneUrl.trim();
if (!reg.test(state.sceneUrl)) {
message.warning($t("urlChecedFail"));
}
//处理realspace带有/
// if (sceneUrl.value.slice(-14) === "rest/realspace") {
// let url = sceneUrl.value.split("rest/realspace")[0] + "rest/realspace";
// }
}
// 打开场景服务
function openScene() {
if (sceneUrl.value == null || sceneUrl.value == "") {
if (state.sceneUrl == null || state.sceneUrl == "") {
return;
}
//去引号
if (sceneUrl.value.charAt(0) == '"' || sceneUrl.value.charAt(0) == "'") {
if (state.sceneUrl.charAt(0) == '"' || state.sceneUrl.charAt(0) == "'") {
let reg = /^['|"](.*)['|"]$/;
sceneUrl.value = sceneUrl.value.replace(reg, "$1");
state.sceneUrl = state.sceneUrl.replace(reg, "$1");
}
if (token.value) {
if (state.token) {
SuperMap3D.Credential.CREDENTIAL = new SuperMap3D.Credential(
sceneToken.value
state.sceneToken
);
}
let promiseResult = layerManagement.openScene(
sceneUrl.value,
"",
"REALSPACE"
);
SuperMap3D.when(promiseResult, function (layers: any) {
let sceneName = state.sceneName == '' ? undefined : state.sceneName;
const promise = window.viewer.scene.open(state.sceneUrl, sceneName, { autoSetView: true });
SuperMap3D.when(promise, function (layers: any) {
layers.forEach((layer: any) => {
layer.selectedColor = SuperMap3D.Color.fromCssColorString("rgba(166,252,252,1)"); // 通过自定义添加的s3m图层,也设置选中色
});
if (window.iEarthConsole) { console.log('scene-layers:', layers); }
message.success($t("openSceneSuccess"));
});
}
// 清除
function clear() {
sceneUrl.value = "";
sceneToken.value = "";
token.value = false;
state.sceneUrl = "";
state.sceneToken = "";
state.token = false;
}
</script>

30 changes: 29 additions & 1 deletion SuperMap iEarth/src/package/addData/layer-mine/layerMine.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@
/>
</div>

<div style="">
<n-checkbox v-model:checked="state.useSenceName">{{ $t("appointSceneName") }}</n-checkbox>
</div>

<div class="row-item-mine" v-if="state.useSenceName">
<span>{{ $t("name") }}</span>
<n-input class="add-input-border" v-model:value="state.sceneName" type="text" style="width: 2.4rem"/>
</div>

<div class="btn-row-item opration">
<n-button
type="info"
Expand Down Expand Up @@ -59,6 +68,8 @@ type stateType = {
columns: any;
tableData: any;
checkedRowKeys: any;
useSenceName:boolean,
sceneName:string;
};
let state = reactive<stateType>({
Expand Down Expand Up @@ -98,6 +109,8 @@ let state = reactive<stateType>({
],
tableData: [],
checkedRowKeys: ["1"],
useSenceName:false,
sceneName: '',
});
// 初始化并获取数据
Expand Down Expand Up @@ -176,7 +189,9 @@ function addService() {
let promiseArray: any = [];
setTrustedServers(url);
let promise = viewer.scene.open(url);
// let promise = viewer.scene.open(url);
let sceneName = state.sceneName == '' ? undefined : state.sceneName;
const promise = viewer.scene.open(url, sceneName, { autoSetView: true });
promiseArray.push(promise);
promiseWhen(promiseArray, true);
});
Expand Down Expand Up @@ -375,4 +390,17 @@ function dateDiff(timestamp) {
margin-top: 0.1rem;
margin-left: 56%;
}
.row-item-mine{
span {
font-size: 0.14rem;
}
display: flex;
justify-content: space-between;
width: 3.4rem;
margin-top: 0.1rem;
margin-right: 0.1rem;
}
</style>

0 comments on commit b6c0ec6

Please sign in to comment.