Skip to content

Commit 1f0e54d

Browse files
【feature】要素关联附件 review by qiwei
1 parent 5e8fa47 commit 1f0e54d

31 files changed

+1738
-127
lines changed

build/jsdocs/template/typeLinkExt.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ var typeLinks = {
131131
"THREE.Shape": threeApi + '#api/extras/core/Shape',
132132

133133
// TF
134-
'tf.GraphModel': 'https://js.tensorflow.org/api/latest/#class:GraphModel'
134+
'tf.GraphModel': 'https://js.tensorflow.org/api/latest/#class:GraphModel',
135+
136+
// File Blob
137+
'File': webApi + 'API/File',
138+
'Blob': webApi + 'API/Blob'
135139
}
136140
exports.typeLinks = typeLinks;
Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
<!--********************************************************************
2+
* Copyright© 2000 - 2023 SuperMap Software Co.Ltd. All rights reserved.
3+
*********************************************************************-->
4+
<!DOCTYPE html>
5+
<html>
6+
7+
<head>
8+
<meta charset="UTF-8">
9+
<title data-i18n="resources.title_editFeatureAttachments"></title>
10+
<script type="text/javascript" src="../../dist/leaflet/include-leaflet.js"></script>
11+
<style>
12+
.editPane {
13+
position: absolute;
14+
right: 65px;
15+
top: 8px;
16+
text-align: center;
17+
background: #FFF;
18+
z-index: 1000;
19+
border-radius: 4px;
20+
}
21+
22+
.attachmentFile {
23+
width: 225px;
24+
}
25+
26+
.leaflet-popup-scrollable {
27+
overflow: auto;
28+
}
29+
30+
.leaflet-popup {
31+
width: 280px;
32+
font-size: 14px;
33+
min-height: 100px;
34+
max-height: 200px;
35+
}
36+
</style>
37+
</head>
38+
39+
<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%; position: absolute;top: 0;">
40+
<div id="map" style="width: 100%;height:100%"></div>
41+
<div class="panel panel-primary editPane" id="editPane">
42+
<div class='panel-heading'>
43+
<h5 class='panel-title text-center' data-i18n="resources.text_editSingle"></h5>
44+
</div>
45+
<div class='panel-body content file' style="padding-bottom: 0;">
46+
<input type='file' id="attachmentFile" class='btn btn-default attachmentFile'
47+
data-i18n="[value]resources.btn_addMarker" />&nbsp;
48+
</div>
49+
<div class='panel-body content'>
50+
<input id="getAttachmentsInput" type='button' class='btn btn-default'
51+
data-i18n="[value]resources.text_getAttachments" onclick='getAttachments()' />
52+
<input id="resetFileInput" type='button' class='btn btn-default' data-i18n="[value]resources.btn_undoAdd"
53+
onclick='resetFile()' />
54+
<input id="commitInput" type='button' class='btn btn-default'
55+
data-i18n="[value]resources.text_input_value_submit" onclick='commit()' />&nbsp;
56+
</div>
57+
</div>
58+
<script type="text/javascript" include="bootstrap,widgets.alert" src="../js/include-web.js"></script>
59+
<script type="text/javascript">
60+
var map, featureId, vectorSource, resultLayer,
61+
host = window.isLocal ? window.server : "https://iserver.supermap.io",
62+
baseUrl = host + "/iserver/services/map-world/rest/maps/World",
63+
url = host + "/iserver/services/data-world/rest/data",
64+
fileDom = document.getElementById('attachmentFile'),
65+
getAttachmentsInputDom = document.getElementById('getAttachmentsInput'),
66+
resetFileInputDom = document.getElementById('resetFileInput'),
67+
commitInputDom = document.getElementById('commitInput'),
68+
file,
69+
showPosition,
70+
lastTarget,
71+
showPosition;
72+
map = L.map('map', {
73+
preferCanvas: true,
74+
crs: L.CRS.EPSG4326,
75+
center: { lon: 0, lat: 0 },
76+
maxZoom: 18,
77+
zoom: 2
78+
});
79+
new L.supermap.TiledMapLayer(baseUrl).addTo(map);
80+
81+
initFeature()
82+
83+
function initFeature() {
84+
setDisabledAndTips(true, resources.msg_noFeature);
85+
var sqlParam = new L.supermap.GetFeaturesBySQLParameters({
86+
queryParameter: {
87+
name: "Countries@World",
88+
attributeFilter: "SMID > 0"
89+
},
90+
datasetNames: ["World:Countries"]
91+
});
92+
new L.supermap.FeatureService(url).getFeaturesBySQL(sqlParam).then(serviceResult => {
93+
resultLayer = L.geoJSON(serviceResult.result.features, {
94+
onEachFeature: function (feature, layer) {
95+
layer.on({
96+
click: (e) => {
97+
if (lastTarget) {
98+
resultLayer.resetStyle(lastTarget);
99+
};
100+
if (e.target) {
101+
lastTarget = e.target;
102+
setDisabledAndTips(false, '');
103+
showPosition = e.target.getCenter();
104+
};
105+
featureId = feature.properties.SMID;
106+
let layer = e.target;
107+
layer.setStyle({
108+
weight: 3,
109+
color: 'red',
110+
dashArray: '',
111+
})
112+
}
113+
})
114+
115+
}
116+
}).addTo(map)
117+
});
118+
}
119+
function getAttachments() {
120+
new L.supermap.DatasetService(url).getDataset("World", "Countries", function (serviceResult) {
121+
if (!serviceResult.result.supportAttachments) {
122+
return widgets.alert.showAlert(resources.msg_notSupportAttachments, false);
123+
}
124+
var params = new L.supermap.AttachmentsParameters({
125+
dataSourceName: "World",
126+
dataSetName: "Countries",
127+
featureId: featureId
128+
});
129+
new L.supermap.FeatureService(url).getFeatureAttachments(params).then(res => {
130+
results = res.result;
131+
let innerHTML = '';
132+
if (results.length > 0) {
133+
results.forEach(function (result) {
134+
var link = `${url}/datasources/${params.dataSourceName}/datasets/${params.dataSetName}/features/${params.featureId}/attachments/${result.id}`;
135+
innerHTML += resources.text_attachmentFileName + ": " + "<a href=" + link + ">" + result.name + "</a>" + "<br>";
136+
innerHTML += resources.text_attachmentFileType + ": " + result.contentType + "<br>";
137+
innerHTML += resources.text_attachmentFileSize + ": " + result.size / 1024 + " KB";
138+
innerHTML += "<hr>";
139+
})
140+
}
141+
L.popup({
142+
minWidth: 180,
143+
maxWidth: 800,
144+
minHeight: 100,
145+
maxHeight: 200,
146+
})
147+
.setLatLng(showPosition)
148+
.setContent(innerHTML || resources.text_noData)
149+
.openOn(map);
150+
});
151+
})
152+
}
153+
154+
function setDisabledAndTips(disabled, tooltip) {
155+
fileDom.disabled = disabled;
156+
getAttachmentsInputDom.disabled = disabled;
157+
resetFileInputDom.disabled = disabled;
158+
commitInputDom.disabled = disabled;
159+
160+
fileDom.setAttribute("title", tooltip);
161+
getAttachmentsInputDom.setAttribute("title", tooltip);
162+
resetFileInputDom.setAttribute("title", tooltip);
163+
commitInputDom.setAttribute("title", tooltip);
164+
}
165+
function resetFile() {
166+
fileDom.value = '';
167+
file = null;
168+
}
169+
function commit() {
170+
new L.supermap.DatasetService(url).getDataset("World", "Countries", function (serviceResult) {
171+
if (!serviceResult.result.supportAttachments) {
172+
return widgets.alert.showAlert(resources.msg_notSupportAttachments, false);
173+
};
174+
file = fileDom.files[0];
175+
if (file) {
176+
var params = new L.supermap.EditAttachmentsParameters({
177+
dataSourceName: "World",
178+
dataSetName: "Countries",
179+
featureId: featureId,
180+
file: file,
181+
editType: 'add'
182+
});
183+
new L.supermap.FeatureService(url).editFeatureAttachments(params).then(serviceResult => {
184+
resetFile();
185+
return widgets.alert.showAlert(resources.msg_submitSuccess, true);
186+
});
187+
} else {
188+
return widgets.alert.showAlert(resources.msg_noAttachment, false);
189+
}
190+
})
191+
}
192+
193+
</script>
194+
</body>
195+
196+
</html>

examples/leaflet/config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,12 @@ var exampleConfig = {
184184
thumbnail: "l_editFeatures.png",
185185
fileName: "02_editFeatures"
186186
},
187+
{
188+
name: "要素关联附件",
189+
name_en: "feature attachment",
190+
thumbnail: "l_featureAttachments.png",
191+
fileName: "02_FeatureAttachment"
192+
},
187193
{
188194
name: "数据源信息查询",
189195
name_en: "datasource information service",
74.8 KB
Loading

examples/locales/en-US/resources.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1314,6 +1314,11 @@ window.examplesResources = {
13141314
"text_keyAuthorizedGetMap": "Key authorized get map",
13151315
"text_tokenAuthorizedGetMap": "Token authorized get map",
13161316
"text_getMap": "Get map",
1317+
"msg_notSupportAttachments": "This dataset does not support the feature of element associated attachments. Please enable it in the iServer service management interface",
1318+
"text_getAttachments": "Get Attachments",
1319+
'text_attachmentFileName': "File name",
1320+
'text_attachmentFileType': "File type",
1321+
'text_attachmentFileSize': "File size",
13171322
"text_iServerAddress": "iServer home page address, such as: http://localhost:8090/iserver",
13181323
"text_iManagerAddress": "iManager home page address,such as: http://localhost:8390/imanager",
13191324
"text_keyAuthorizedService": "key authorized access to private services",
@@ -1883,10 +1888,13 @@ window.examplesResources = {
18831888
"msg_chooseColor": "Please choose color value",
18841889
"msg_repeatedAdditions": "Repeated Additions!",
18851890
"msg_noDataRedraw": "No data has been obtained, please redraw",
1891+
"msg_noAttachment": "There is no new file to be submitted, please add file firstly.",
1892+
"msg_noFeature": "There is no feature, please select a feature first.",
18861893
"msg_noRevocableMarker": "There is no revocable marker.",
18871894
"msg_noMarkerToSubmit": "There is no new marker to be submitted, please add new marker firstly.",
18881895
"msg_noNewFeature": "There is no new marker, please add new marker firstly.",
1889-
"msg_submitSuccess": "Successful submission",
1896+
"msg_submitSuccess": "submission Successful",
1897+
"msg_submitFailed": "Submission failed",
18901898
"msg_selectDeletePoint": "Please select the point that you need to delete.",
18911899
"msg_deleteFailed": "Delete failed",
18921900
"msg_queryMileagePoint1": "The mileage point is ",

examples/locales/zh-CN/resources.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,6 +1268,11 @@ window.examplesResources = {
12681268
"text_keyAuthorizedGetMap": "key授权出图",
12691269
"text_tokenAuthorizedGetMap": "token授权出图",
12701270
"text_getMap": "出图",
1271+
"msg_notSupportAttachments": "该数据集不支持要素关联附件功能,请到iServer服务管理界面进行开启",
1272+
"text_getAttachments": "获取附件",
1273+
'text_attachmentFileName': "文件名称",
1274+
'text_attachmentFileType': "文件类型",
1275+
'text_attachmentFileSize': "文件大小",
12711276
"text_iServerAddress": "iServer首页地址,如:http://localhost:8090/iserver",
12721277
"text_iManagerAddress": "iManager首页地址,如http://localhost:8390/imanager",
12731278
"text_keyAuthorizedService": "key授权访问私有服务",
@@ -1835,10 +1840,13 @@ window.examplesResources = {
18351840
"msg_chooseColor": "请选颜色值",
18361841
"msg_repeatedAdditions": "重复添加!",
18371842
"msg_noDataRedraw": "没有获取到数据,请重新绘制",
1843+
"msg_noAttachment": "没有获取到附件,请上传",
1844+
"msg_noFeature": "没有获取到要素,请选择要素",
18381845
"msg_noRevocableMarker": "没有可撤回的要素。",
18391846
"msg_noMarkerToSubmit": "没有可提交的新要素,请先添加新要素。",
18401847
"msg_noNewFeature": "没有新增要素,请先添加新要素。",
18411848
"msg_submitSuccess": "提交成功",
1849+
"msg_submitFailed": "提交失败,",
18421850
"msg_selectDeletePoint": "请选择需要删除的点",
18431851
"msg_deleteFailed": "删除失败",
18441852
"msg_queryMileagePoint1": "查询到的里程为 ",

0 commit comments

Comments
 (0)