Skip to content

Commit c566817

Browse files
committed
新增添加地图/添加场景示例 --committed by wangzhe,reviewed by huangqh
1 parent 482abba commit c566817

File tree

12 files changed

+547
-3
lines changed

12 files changed

+547
-3
lines changed

examples/leaflet/config.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,17 @@ var exampleConfig = {
493493
thumbnail: "l_iPortalQueryMyResources.png",
494494
fileName: "iPortalQueryMyResources"
495495
}]
496+
},
497+
"ip_batchaddresource": {
498+
name: "添加地图/场景",
499+
name_en: "Batch Add Map/Scene",
500+
content: [{
501+
name: "添加地图/场景",
502+
name_en: "Batch Add Map/Scene",
503+
version: "10.0.1",
504+
thumbnail: "l_iPortalQueryResources.png",
505+
fileName: "iPortalBatchAddResource"
506+
}]
496507
}
497508
}
498509
},
Lines changed: 245 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,245 @@
1+
<!--********************************************************************
2+
* Copyright© 2000 - 2020 SuperMap Software Co.Ltd. All rights reserved.
3+
*********************************************************************-->
4+
<!DOCTYPE html>
5+
<html lang="en">
6+
<head>
7+
<meta charset="UTF-8">
8+
<title data-i18n="resources.title_iPortalAddMapOrScene"></title>
9+
<style>
10+
.title-checkbox-container p{
11+
max-width: 150px;
12+
float: left;
13+
}
14+
.title-checkbox-container input{
15+
float: right;
16+
}
17+
#plottingPanel {
18+
float: left;
19+
background: #ffffff;
20+
width: 250px;
21+
height: 100%;
22+
border: 1px solid #3473b7;
23+
}
24+
.datagrid-cell {
25+
word-break: break-all;
26+
white-space: normal!important;
27+
}
28+
.tabs-container ,.tabs-panels,.panel-body{
29+
height: auto!important;
30+
}
31+
.panel-title {
32+
margin-top: 0!important;
33+
margin-bottom: 0!important;
34+
font-size: 16px!important;
35+
color: inherit!important;
36+
}
37+
</style>
38+
</head>
39+
<body style=" margin: 0;overflow: auto;background: #F2F2F2;width: 100%;height:100%;position: absolute;top: 0;">
40+
<!-- 资源过滤 and 资源展示 -->
41+
<div class="container" style="margin-bottom: 100px;">
42+
<div class="page-header">
43+
<h4 id="resourceTypeText" data-i18n="resources.title_iPortalAddMap"></h4>
44+
</div>
45+
<br />
46+
<div class="col-md-12">
47+
<div class="row">
48+
<div class="col-md-12" style="background: #FFF;">
49+
<!--添加资源-->
50+
<div class="row" id="batch-add-resource" style="padding: 10px;">
51+
<h5 data-i18n="resources.title_iPortalQueryResourcesType"></h5>
52+
<select id='typeSelect' class='form-control' onchange="onSelectResourcesType()">
53+
<option value="MAP" data-i18n="resources.title_iPortalQueryResourcesMap"></option>
54+
<option value="SCENE" data-i18n="resources.title_iPortalQueryResourcesScene"></option>
55+
</select>
56+
<h5 data-i18n="resources.text_serviceAddress"></h5>
57+
<span style="position: relative;">
58+
<input id="address" class='form-control' type="text" style="width: 100%;"><i class="fa fa-question-circle question" aria-hidden="true"></i>
59+
</span>
60+
<h5 data-i18n="resources.detail_iPortal_tags"></h5>
61+
<input id="tags" class='form-control' type="text" style="width: 100%;" data-i18n="[placeholder]resources.text_userMap">
62+
<h5 data-i18n="resources.title_share_setting"></h5>
63+
<div>
64+
<form class="form-horizontal">
65+
<fieldset>
66+
<ul class="nav nav-tabs" role="tablist">
67+
<li role="presentation" class="active">
68+
<a href="#public" aria-controls="public" role="tab" data-toggle="tab" data-i18n="resources.title_iPortalQueryResourcesPublic"></a>
69+
</li>
70+
</ul>
71+
<div class="tab-content">
72+
<div role="tabpanel" class="tab-pane active" id="public">
73+
<div class="col-md-4 gallery-item" id="shareCheckboxs">
74+
<div class="publicPane sub-font">
75+
<input id="search" type="checkbox" value="search" onclick="clickSearchCheckBox()" />
76+
&nbsp;<label for="search" data-i18n="resources.text_user_search"></label>
77+
</div>
78+
<div class="publicPane sub-font">
79+
<input id="view" type="checkbox" value="view" onclick="clickViewCheckBox()" />
80+
&nbsp;<label for="view" data-i18n="resources.text_user_view"></label>
81+
</div>
82+
<div class="publicPane sub-font">
83+
<input id="edit" type="checkbox" value="edit" onclick="clickEditCheckBox()" />
84+
&nbsp;<label for="edit" data-i18n="resources.text_user_editor"></label>
85+
</div>
86+
</div>
87+
</div>
88+
</div>
89+
</fieldset>
90+
</form>
91+
</div>
92+
<div><button class="btn btn-primary col-md-offset-6" style="margin-top: 20px;" onclick="addMapOrScene()" data-i18n="resources.btn_OK"></button></div>
93+
</div>
94+
</div>
95+
</div>
96+
</div>
97+
</div>
98+
<script type="text/javascript" include="jquery,bootstrap,plottingPanel,widgets" src="../js/include-web.js"></script>
99+
<script type="text/javascript" include="iclient-plot-leaflet" src="../../dist/leaflet/include-leaflet.js"></script>
100+
<script type="text/javascript" include="iPortalStylePanel" src="../js/plottingPanel/PlottingPanel.Include.js"></script>
101+
<script>
102+
//iportal的URL地址 或根据情况添加自己的本地iportal地址:http://localhost:8091/iportal
103+
var iPortalUrl = "http://rdc.ispeco.com/";
104+
// rdc的admin用户的token,模拟admin用户登录状态
105+
var token = "qbzq4N7oA7sC6xJwP_VzbtEqoscT-sLATh83DzePead0gK4Tf5qEnypDY0iO3x7qM4pRSQxM98Zr5WAxLZhONw..";
106+
//默认请求资源类型
107+
var resourceType = "MAP";
108+
//共享设置
109+
var publicSettingEntity = {
110+
"permissionType": "",
111+
"entityType": "USER",
112+
"entityName": "GUEST",
113+
"entityId": null,
114+
"authorizeList": []
115+
}
116+
function getDefaultUrl(){
117+
iPortalUser = new SuperMap.iPortalUser(iPortalUrl);
118+
}
119+
// 注册token
120+
function generatePortalToken() {
121+
let serverInfo = new SuperMap.ServerInfo(SuperMap.ServerType.IPORTAL, {
122+
server: iPortalUrl
123+
});
124+
125+
SuperMap.SecurityManager.registerServers([serverInfo]);
126+
SuperMap.SecurityManager.destroyToken(iPortalUrl);
127+
SuperMap.SecurityManager.registerToken(iPortalUrl, token);
128+
}
129+
// 添加地图/场景
130+
function addMapOrScene() {
131+
generatePortalToken();
132+
iPortalUser = new SuperMap.iPortalUser(iPortalUrl);
133+
let params = new SuperMap.iPortalAddResourceParam({
134+
rootUrl: $("#address").val(),
135+
tags: $("#tags").val(),
136+
entities: getShareEntities()
137+
});
138+
if(resourceType === "MAP") {
139+
iPortalUser.addMap(params).then(res => {
140+
if(res.succeed) {
141+
widgets.alert.showAlert(resources.msg_addSuccess, true);
142+
} else {
143+
widgets.alert.showAlert(resources.msg_addFailed, false);
144+
}
145+
})
146+
}
147+
if(resourceType === "SCENE") {
148+
iPortalUser.addScene(params).then(res => {
149+
if(res.succeed) {
150+
widgets.alert.showAlert(resources.msg_addSuccess, true);
151+
} else {
152+
widgets.alert.showAlert(resources.msg_addFailed, false);
153+
}
154+
})
155+
}
156+
}
157+
function getShareEntities(){
158+
shareSettingList = [];
159+
//公开
160+
addSettingEntity(publicSettingEntity);
161+
return shareSettingList;
162+
}
163+
//生成分享的entities参数
164+
function addSettingEntity(obj){
165+
var settingEntity = dealShareSettingParam(obj);
166+
if(settingEntity){
167+
shareSettingList.push(settingEntity);
168+
}
169+
}
170+
function dealShareSettingParam(obj) {
171+
var authorize = "";
172+
if(!obj.authorizeList){
173+
return null;
174+
}
175+
if(obj.authorizeList.includes("edit")){
176+
authorize = "READWRITE";
177+
}else if(obj.authorizeList.includes("view")){
178+
authorize = "READ";
179+
}else if(obj.authorizeList.includes("download")){
180+
authorize = "DOWNLOAD";
181+
}else if(obj.authorizeList.includes("search")){
182+
authorize = "SEARCH";
183+
}
184+
if(authorize){
185+
if(resourceType === "data") {
186+
obj.dataPermissionType = authorize;
187+
}
188+
obj.permissionType = authorize;
189+
let targetPermissionEntity = Object.assign({},obj);
190+
delete targetPermissionEntity.authorizeList;
191+
delete targetPermissionEntity.aliasName;
192+
delete targetPermissionEntity.entityRoles;
193+
return targetPermissionEntity;
194+
}else {
195+
return null;
196+
}
197+
}
198+
// 选择资源类型
199+
function onSelectResourcesType(){
200+
let type = $("#typeSelect").val();
201+
resourceType = type;
202+
if(resourceType === "MAP") {
203+
$("#resourceTypeText")[0].innerText = resources.title_iPortalAddMap;
204+
} else if(resourceType === "SCENE") {
205+
$("#resourceTypeText")[0].innerText = resources.title_iPortalAddScene;
206+
}
207+
$("#address").val("");
208+
$("#tags").val("");
209+
}
210+
// 点击所有用户可检索
211+
function clickSearchCheckBox(){
212+
if(!publicSettingEntity.authorizeList || (publicSettingEntity.authorizeList).indexOf("search") === -1){
213+
publicSettingEntity.authorizeList = ["search"];
214+
}else {
215+
publicSettingEntity.authorizeList = [];
216+
}
217+
publicSettingEntity.authorizeList.forEach( authorizeListItem=> {
218+
$("input[value='"+authorizeListItem+"']").prop("checked", true);
219+
})
220+
}
221+
// 点击所有用户可查看
222+
function clickViewCheckBox(){
223+
if(!publicSettingEntity.authorizeList || (publicSettingEntity.authorizeList).indexOf("view") === -1){
224+
publicSettingEntity.authorizeList = ["search","view"];
225+
}else if((publicSettingEntity.authorizeList).indexOf("search") !== -1){
226+
publicSettingEntity.authorizeList = ["search"];
227+
}
228+
publicSettingEntity.authorizeList.forEach( authorizeListItem=> {
229+
$("input[value='"+authorizeListItem+"']").prop("checked", true);
230+
})
231+
}
232+
// 点击所有用户可编辑
233+
function clickEditCheckBox(){
234+
if(!publicSettingEntity.authorizeList || (publicSettingEntity.authorizeList).indexOf("edit") === -1){
235+
publicSettingEntity.authorizeList = ["search","view","edit"];
236+
}else if((publicSettingEntity.authorizeList).indexOf("view") !== -1){
237+
publicSettingEntity.authorizeList = ["search","view"];
238+
}
239+
publicSettingEntity.authorizeList.forEach( authorizeListItem=> {
240+
$("input[value='"+authorizeListItem+"']").prop("checked", true);
241+
})
242+
}
243+
</script>
244+
</body>
245+
</html>

examples/locales/en-US/resources.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,9 @@ window.examplesResources = {
529529
"title_iPortalQueryScenes1": "Examples of iPortal QueryScenes",
530530
"title_iPortalQueryScene": "Examples of iPortal QueryScene",
531531
"title_iPortalUpdateSceneAttrs": "Examples of iPortal UpdateSceneAttrs",
532+
"title_iPortalAddMapOrScene": "Examples of iPortal AddMap/AddScene",
533+
"title_iPortalAddMap": "Add Map",
534+
"title_iPortalAddScene": "Add Scene",
532535

533536
"detail_iPortal_baseInfo": "Basic Info",
534537
"detail_iPortal_name": "Name",
@@ -1333,6 +1336,7 @@ window.examplesResources = {
13331336
'text_is_view': "View",
13341337
'text_is_edit': "Edit",
13351338
'text_is_download': "Download",
1339+
'text_userMap': "Map from users",
13361340
"title_componentsTianditu_Vue": 'Tianditu',
13371341
"title_componentsTianditu_route_Vue": 'Route Plan',
13381342
"title_componentsTianditu_search_Vue": 'POI Search',
@@ -1520,6 +1524,7 @@ window.examplesResources = {
15201524
"btn_darkTheme":"Dark theme",
15211525
"btn_customTheme":"Custom theme",
15221526
"btn_switchTheme":"Switch theme",
1527+
"btn_OK":"OK",
15231528

15241529
"msg_user_not_exist":"This user doesn't exist",
15251530
"msg_department_not_exist":"This department doesn't exist",
@@ -1639,6 +1644,8 @@ window.examplesResources = {
16391644
"msg_vectorClip": "Vector clipping analysis only supports single side clipping!",
16401645
"msg_clickToPopup": 'Please click the map to open popup',
16411646
"msg_clickLayerToPopup": 'Please click the layer\'s feature to check properties',
1647+
"msg_addSuccess": "Added successfully!",
1648+
"msg_addFailed": "Added failed!",
16421649

16431650
"set_style": "",
16441651
"style_width420px": 'width: 500px',

examples/locales/zh-CN/resources.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,9 @@ window.examplesResources = {
470470
"title_iPortalQueryScenes1": "iPortal QueryScenes使用示例",
471471
"title_iPortalQueryScene": "iPortal QueryScene使用示例",
472472
"title_iPortalUpdateSceneAttrs": "iPortal UpdateSceneAttrs使用示例",
473+
"title_iPortalAddMapOrScene": "iPortal 添加地图/场景使用示例",
474+
"title_iPortalAddMap": "添加地图",
475+
"title_iPortalAddScene": "添加场景",
473476

474477
"detail_iPortal_baseInfo": "基本信息",
475478
"detail_iPortal_name": "名称",
@@ -1284,6 +1287,7 @@ window.examplesResources = {
12841287
'text_is_view': "可查看",
12851288
'text_is_edit': "可编辑",
12861289
'text_is_download': "可下载",
1290+
'text_userMap': "用户地图",
12871291

12881292

12891293
"btn_operate": "操作",
@@ -1468,6 +1472,7 @@ window.examplesResources = {
14681472
"btn_darkTheme":"深色主题",
14691473
"btn_customTheme":"自定义主题",
14701474
"btn_switchTheme":"切换主题",
1475+
"btn_OK":"确定",
14711476

14721477
"msg_user_not_exist":"该用户不存在",
14731478
"msg_department_not_exist":"该部门不存在",
@@ -1587,6 +1592,8 @@ window.examplesResources = {
15871592
"msg_vectorClip": "矢量裁剪分析仅支持单面裁剪!",
15881593
"msg_clickToPopup": '点击地图,弹出弹窗',
15891594
"msg_clickLayerToPopup": '点击图层上的要素,查看属性',
1595+
"msg_addSuccess": "添加成功!",
1596+
"msg_addFailed": "添加失败!",
15901597

15911598
"set_style": "top: -23px;left: 86px;",
15921599
"style_width420px": 'width: 420px',

examples/openlayers/config.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,17 @@ var exampleConfig = {
461461
thumbnail: "ol_iPortalQueryMyResources.png",
462462
fileName: "iPortalQueryMyResources"
463463
}]
464+
},
465+
"ip_batchaddresource": {
466+
name: "添加地图/场景",
467+
name_en: "Batch Add Map/Scene",
468+
content: [{
469+
name: "添加地图/场景",
470+
name_en: "Batch Add Map/Scene",
471+
version: "10.0.1",
472+
thumbnail: "ol_iPortalQueryMyResources.png",
473+
fileName: "iPortalBatchAddResource"
474+
}]
464475
}
465476
}
466477
},

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy