Skip to content

Commit

Permalink
【feature】要素关联附件 review by qiwei
Browse files Browse the repository at this point in the history
  • Loading branch information
shallowdream218 committed Dec 12, 2023
1 parent 5e8fa47 commit 1f0e54d
Show file tree
Hide file tree
Showing 31 changed files with 1,738 additions and 127 deletions.
6 changes: 5 additions & 1 deletion build/jsdocs/template/typeLinkExt.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ var typeLinks = {
"THREE.Shape": threeApi + '#api/extras/core/Shape',

// TF
'tf.GraphModel': 'https://js.tensorflow.org/api/latest/#class:GraphModel'
'tf.GraphModel': 'https://js.tensorflow.org/api/latest/#class:GraphModel',

// File Blob
'File': webApi + 'API/File',
'Blob': webApi + 'API/Blob'
}
exports.typeLinks = typeLinks;
196 changes: 196 additions & 0 deletions examples/leaflet/02_FeatureAttachment.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
<!--********************************************************************
* Copyright© 2000 - 2023 SuperMap Software Co.Ltd. All rights reserved.
*********************************************************************-->
<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<title data-i18n="resources.title_editFeatureAttachments"></title>
<script type="text/javascript" src="../../dist/leaflet/include-leaflet.js"></script>
<style>
.editPane {
position: absolute;
right: 65px;
top: 8px;
text-align: center;
background: #FFF;
z-index: 1000;
border-radius: 4px;
}

.attachmentFile {
width: 225px;
}

.leaflet-popup-scrollable {
overflow: auto;
}

.leaflet-popup {
width: 280px;
font-size: 14px;
min-height: 100px;
max-height: 200px;
}
</style>
</head>

<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%; position: absolute;top: 0;">
<div id="map" style="width: 100%;height:100%"></div>
<div class="panel panel-primary editPane" id="editPane">
<div class='panel-heading'>
<h5 class='panel-title text-center' data-i18n="resources.text_editSingle"></h5>
</div>
<div class='panel-body content file' style="padding-bottom: 0;">
<input type='file' id="attachmentFile" class='btn btn-default attachmentFile'
data-i18n="[value]resources.btn_addMarker" />&nbsp;
</div>
<div class='panel-body content'>
<input id="getAttachmentsInput" type='button' class='btn btn-default'
data-i18n="[value]resources.text_getAttachments" onclick='getAttachments()' />
<input id="resetFileInput" type='button' class='btn btn-default' data-i18n="[value]resources.btn_undoAdd"
onclick='resetFile()' />
<input id="commitInput" type='button' class='btn btn-default'
data-i18n="[value]resources.text_input_value_submit" onclick='commit()' />&nbsp;
</div>
</div>
<script type="text/javascript" include="bootstrap,widgets.alert" src="../js/include-web.js"></script>
<script type="text/javascript">
var map, featureId, vectorSource, resultLayer,
host = window.isLocal ? window.server : "https://iserver.supermap.io",
baseUrl = host + "/iserver/services/map-world/rest/maps/World",
url = host + "/iserver/services/data-world/rest/data",
fileDom = document.getElementById('attachmentFile'),
getAttachmentsInputDom = document.getElementById('getAttachmentsInput'),
resetFileInputDom = document.getElementById('resetFileInput'),
commitInputDom = document.getElementById('commitInput'),
file,
showPosition,
lastTarget,
showPosition;
map = L.map('map', {
preferCanvas: true,
crs: L.CRS.EPSG4326,
center: { lon: 0, lat: 0 },
maxZoom: 18,
zoom: 2
});
new L.supermap.TiledMapLayer(baseUrl).addTo(map);

initFeature()

function initFeature() {
setDisabledAndTips(true, resources.msg_noFeature);
var sqlParam = new L.supermap.GetFeaturesBySQLParameters({
queryParameter: {
name: "Countries@World",
attributeFilter: "SMID > 0"
},
datasetNames: ["World:Countries"]
});
new L.supermap.FeatureService(url).getFeaturesBySQL(sqlParam).then(serviceResult => {
resultLayer = L.geoJSON(serviceResult.result.features, {
onEachFeature: function (feature, layer) {
layer.on({
click: (e) => {
if (lastTarget) {
resultLayer.resetStyle(lastTarget);
};
if (e.target) {
lastTarget = e.target;
setDisabledAndTips(false, '');
showPosition = e.target.getCenter();
};
featureId = feature.properties.SMID;
let layer = e.target;
layer.setStyle({
weight: 3,
color: 'red',
dashArray: '',
})
}
})

}
}).addTo(map)
});
}
function getAttachments() {
new L.supermap.DatasetService(url).getDataset("World", "Countries", function (serviceResult) {
if (!serviceResult.result.supportAttachments) {
return widgets.alert.showAlert(resources.msg_notSupportAttachments, false);
}
var params = new L.supermap.AttachmentsParameters({
dataSourceName: "World",
dataSetName: "Countries",
featureId: featureId
});
new L.supermap.FeatureService(url).getFeatureAttachments(params).then(res => {
results = res.result;
let innerHTML = '';
if (results.length > 0) {
results.forEach(function (result) {
var link = `${url}/datasources/${params.dataSourceName}/datasets/${params.dataSetName}/features/${params.featureId}/attachments/${result.id}`;
innerHTML += resources.text_attachmentFileName + ": " + "<a href=" + link + ">" + result.name + "</a>" + "<br>";
innerHTML += resources.text_attachmentFileType + ": " + result.contentType + "<br>";
innerHTML += resources.text_attachmentFileSize + ": " + result.size / 1024 + " KB";
innerHTML += "<hr>";
})
}
L.popup({
minWidth: 180,
maxWidth: 800,
minHeight: 100,
maxHeight: 200,
})
.setLatLng(showPosition)
.setContent(innerHTML || resources.text_noData)
.openOn(map);
});
})
}

function setDisabledAndTips(disabled, tooltip) {
fileDom.disabled = disabled;
getAttachmentsInputDom.disabled = disabled;
resetFileInputDom.disabled = disabled;
commitInputDom.disabled = disabled;

fileDom.setAttribute("title", tooltip);
getAttachmentsInputDom.setAttribute("title", tooltip);
resetFileInputDom.setAttribute("title", tooltip);
commitInputDom.setAttribute("title", tooltip);
}
function resetFile() {
fileDom.value = '';
file = null;
}
function commit() {
new L.supermap.DatasetService(url).getDataset("World", "Countries", function (serviceResult) {
if (!serviceResult.result.supportAttachments) {
return widgets.alert.showAlert(resources.msg_notSupportAttachments, false);
};
file = fileDom.files[0];
if (file) {
var params = new L.supermap.EditAttachmentsParameters({
dataSourceName: "World",
dataSetName: "Countries",
featureId: featureId,
file: file,
editType: 'add'
});
new L.supermap.FeatureService(url).editFeatureAttachments(params).then(serviceResult => {
resetFile();
return widgets.alert.showAlert(resources.msg_submitSuccess, true);
});
} else {
return widgets.alert.showAlert(resources.msg_noAttachment, false);
}
})
}

</script>
</body>

</html>
6 changes: 6 additions & 0 deletions examples/leaflet/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ var exampleConfig = {
thumbnail: "l_editFeatures.png",
fileName: "02_editFeatures"
},
{
name: "要素关联附件",
name_en: "feature attachment",
thumbnail: "l_featureAttachments.png",
fileName: "02_FeatureAttachment"
},
{
name: "数据源信息查询",
name_en: "datasource information service",
Expand Down
Binary file added examples/leaflet/img/l_featureAttachments.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 9 additions & 1 deletion examples/locales/en-US/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -1314,6 +1314,11 @@ window.examplesResources = {
"text_keyAuthorizedGetMap": "Key authorized get map",
"text_tokenAuthorizedGetMap": "Token authorized get map",
"text_getMap": "Get map",
"msg_notSupportAttachments": "This dataset does not support the feature of element associated attachments. Please enable it in the iServer service management interface",
"text_getAttachments": "Get Attachments",
'text_attachmentFileName': "File name",
'text_attachmentFileType': "File type",
'text_attachmentFileSize': "File size",
"text_iServerAddress": "iServer home page address, such as: http://localhost:8090/iserver",
"text_iManagerAddress": "iManager home page address,such as: http://localhost:8390/imanager",
"text_keyAuthorizedService": "key authorized access to private services",
Expand Down Expand Up @@ -1883,10 +1888,13 @@ window.examplesResources = {
"msg_chooseColor": "Please choose color value",
"msg_repeatedAdditions": "Repeated Additions!",
"msg_noDataRedraw": "No data has been obtained, please redraw",
"msg_noAttachment": "There is no new file to be submitted, please add file firstly.",
"msg_noFeature": "There is no feature, please select a feature first.",
"msg_noRevocableMarker": "There is no revocable marker.",
"msg_noMarkerToSubmit": "There is no new marker to be submitted, please add new marker firstly.",
"msg_noNewFeature": "There is no new marker, please add new marker firstly.",
"msg_submitSuccess": "Successful submission",
"msg_submitSuccess": "submission Successful",
"msg_submitFailed": "Submission failed",
"msg_selectDeletePoint": "Please select the point that you need to delete.",
"msg_deleteFailed": "Delete failed",
"msg_queryMileagePoint1": "The mileage point is ",
Expand Down
8 changes: 8 additions & 0 deletions examples/locales/zh-CN/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -1268,6 +1268,11 @@ window.examplesResources = {
"text_keyAuthorizedGetMap": "key授权出图",
"text_tokenAuthorizedGetMap": "token授权出图",
"text_getMap": "出图",
"msg_notSupportAttachments": "该数据集不支持要素关联附件功能,请到iServer服务管理界面进行开启",
"text_getAttachments": "获取附件",
'text_attachmentFileName': "文件名称",
'text_attachmentFileType': "文件类型",
'text_attachmentFileSize': "文件大小",
"text_iServerAddress": "iServer首页地址,如:http://localhost:8090/iserver",
"text_iManagerAddress": "iManager首页地址,如http://localhost:8390/imanager",
"text_keyAuthorizedService": "key授权访问私有服务",
Expand Down Expand Up @@ -1835,10 +1840,13 @@ window.examplesResources = {
"msg_chooseColor": "请选颜色值",
"msg_repeatedAdditions": "重复添加!",
"msg_noDataRedraw": "没有获取到数据,请重新绘制",
"msg_noAttachment": "没有获取到附件,请上传",
"msg_noFeature": "没有获取到要素,请选择要素",
"msg_noRevocableMarker": "没有可撤回的要素。",
"msg_noMarkerToSubmit": "没有可提交的新要素,请先添加新要素。",
"msg_noNewFeature": "没有新增要素,请先添加新要素。",
"msg_submitSuccess": "提交成功",
"msg_submitFailed": "提交失败,",
"msg_selectDeletePoint": "请选择需要删除的点",
"msg_deleteFailed": "删除失败",
"msg_queryMileagePoint1": "查询到的里程为 ",
Expand Down
Loading

0 comments on commit 1f0e54d

Please sign in to comment.