Skip to content

Commit d5b45f4

Browse files
committed
【feature】 datasouce 和 dataset 接口的封装;review by xiongjj
1 parent 4828ae2 commit d5b45f4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+4249
-3
lines changed

build/jsdocs/template/config.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@
5555
"FeatureResults": {
5656
"name": "数据查询",
5757
"name_en": "FeatureResults"
58+
},
59+
"Datasource": {
60+
"name": "数据源",
61+
"name_en": "Datasource"
62+
},
63+
"Dataset": {
64+
"name": "数据集",
65+
"name_en": "Dataset"
5866
}
5967
}
6068
},

examples/classic/config.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,19 @@ var exampleConfig = {
413413
name_en: "data gridcell query",
414414
thumbnail: "query_gridInfosQuery.png",
415415
fileName: "query_gridInfosQuery"
416-
}]
416+
}, {
417+
name: "数据源信息查询",
418+
name_en: "datasource information service",
419+
thumbnail: "query_datasourceInfo.png",
420+
fileName: "query_datasourceInfo"
421+
},
422+
{
423+
name: "数据集信息查询",
424+
name_en: "dataset information service",
425+
thumbnail: "query_datasetInfo.png",
426+
fileName: "query_datasetInfo"
427+
}
428+
]
417429
}
418430

419431
}
19.1 KB
Loading
18.6 KB
Loading
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
<!--********************************************************************
2+
* Copyright© 2000 - 2021 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_DatasetInfo"></title>
10+
<script type="text/javascript" include="bootstrap" src="../js/include-web.js"></script>
11+
<style type="text/css">
12+
body {
13+
margin: 0;
14+
overflow: hidden;
15+
background: #fff;
16+
width: 100%;
17+
height: 100%
18+
}
19+
20+
#map {
21+
position: absolute;
22+
width: 100%;
23+
height: 100%;
24+
}
25+
26+
#toolbar {
27+
position: absolute;
28+
top: 50px;
29+
right: 10px;
30+
width: 300px;
31+
text-align: center;
32+
z-index: 100;
33+
border-radius: 4px;
34+
}
35+
36+
/* 用户自定义-弹框内容样式 */
37+
#pop-content {
38+
right: 0 !important;
39+
padding-left: 20px;
40+
color: #000;
41+
word-wrap: break-word;
42+
margin-top: 10px;
43+
}
44+
</style>
45+
</head>
46+
47+
<body>
48+
<div id="toolbar" class="panel panel-primary">
49+
<div class='panel-heading'>
50+
<h5 class='panel-title text-center' data-i18n="resources.title_DatasetInfo"></h5>
51+
</div>
52+
<div class='panel-body content'>
53+
<div class='panel'>
54+
<div class='input-group'>
55+
<span class='input-group-addon' data-i18n="resources.text_Datasources"></span>
56+
<select id='datasourcesSelect' class='form-control'></select>
57+
</div>
58+
</div>
59+
<div class='panel'>
60+
<div class='input-group'>
61+
<span class='input-group-addon' data-i18n="resources.text_dataset"></span>
62+
<select id='datasetsSelect' class='form-control'></select>
63+
</div>
64+
</div>
65+
<input type="button" class="btn btn-default" data-i18n="[value]resources.btn_query"
66+
onclick="datasetsPrint()" />
67+
</div>
68+
</div>
69+
<div id="map"></div>
70+
<div id="popup" class="ol-popup">
71+
<a href="#" id="popup-closer" class="ol-popup-closer"></a>
72+
<div id="popup-content"></div>
73+
</div>
74+
<script type="text/javascript" include="infoWindow" src="../../dist/classic/include-classic.js"></script>
75+
<script>
76+
let host = window.isLocal ? window.server : "https://iserver.supermap.io";
77+
let map, layer,datasetsSelect,datasourcesSelect,
78+
url1 = host + "/iserver/services/map-world/rest/maps/World",
79+
url2 = host + "/iserver/services/data-world/rest/data";
80+
81+
init()
82+
function init() {
83+
map = new SuperMap.Map("map", {
84+
controls: [
85+
new SuperMap.Control.Zoom(),
86+
new SuperMap.Control.Navigation({
87+
dragPanOptions: {
88+
enableKinetic: true
89+
}
90+
})]
91+
});
92+
layer = new SuperMap.Layer.TiledDynamicRESTLayer("World", url1, {
93+
transparent: true, cacheEnabled: true
94+
}, { maxResolution: "auto" });
95+
layer.events.on({ "layerInitialized": addLayer });
96+
//初始化popup类
97+
markerPop = new SuperMap.InfoWindow(
98+
"marker"
99+
);
100+
}
101+
102+
function addLayer() {
103+
map.addLayers([layer]);
104+
map.setCenter(new SuperMap.LonLat(0, 0), 0);
105+
dataSourcesService();
106+
}
107+
108+
function dataSourcesService() {
109+
new SuperMap.REST.DatasourceService(url2).getDatasources(function (serviceResult) {
110+
datasourcesSelect = document.getElementById("datasourcesSelect");
111+
const datasourceNames = serviceResult.result.datasourceNames;
112+
for (let i = 0,len = serviceResult.result.datasourceNames.length; i < len; i++) {
113+
datasourcesSelect.options[i] = new Option(datasourceNames[i], datasourceNames[i]);
114+
}
115+
const datasourceName = datasourcesSelect.value;
116+
datasetsService(datasourceName)
117+
});
118+
119+
};
120+
121+
//数据集信息
122+
function datasetsService(datasourceName) {
123+
new SuperMap.REST.DatasetService(url2).getDatasets(datasourceName, function (serviceResult) {
124+
const datasetNames = serviceResult.result.datasetNames;
125+
datasetsSelect = document.getElementById("datasetsSelect");
126+
for (let i = 0, len = datasetNames.length; i < len; i++) {
127+
datasetsSelect.options[i] = new Option(datasetNames[i], datasetNames[i]);
128+
}
129+
});
130+
}
131+
132+
function datasetsPrint() {
133+
const datasourceName = datasourcesSelect.value;
134+
const datasetName = datasetsSelect.value;
135+
new SuperMap.REST.DatasetService(url2).getDataset(datasourceName,datasetName, function (serviceResult) {
136+
markerPop.hide();
137+
markerPop.titleBox = true;
138+
markerPop.contentSize = new SuperMap.Size(240, 150);
139+
markerPop.render();
140+
markerPop.setContentHTML(null, '<div id="pop-content">' + "(" + resources.text_datasetInfoPrint + ")" + "<br>" +
141+
"dataSourceName:" + JSON.stringify(serviceResult.result.datasetInfo.dataSourceName, null, 2) + "<br>" +
142+
"description:" + JSON.stringify(serviceResult.result.datasetInfo.description, null, 2) + "<br>" +
143+
"isFileCache:" + JSON.stringify(serviceResult.result.datasetInfo.isFileCache, null, 2) + "<br>" +
144+
"name:" + JSON.stringify(serviceResult.result.datasetInfo.name, null, 2) + "<br>" +
145+
"prjCoordSys:" + "(...)" + "<br>" + '</div>');
146+
markerPop.setLonLat(map.getCenter(), { x: 0, y: 0 });
147+
//添加弹窗到map图层
148+
map.addPopup(markerPop);
149+
});
150+
}
151+
152+
// Feature取消选中事件响应
153+
function onFeatureUnselect() {
154+
markerPop.destroy();
155+
}
156+
</script>
157+
158+
</body>
159+
160+
</html>
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
<!--********************************************************************
2+
* Copyright© 2000 - 2021 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_DatasourceInfo"></title>
10+
<script type="text/javascript" include="bootstrap" src="../js/include-web.js"></script>
11+
<style type="text/css">
12+
body {
13+
margin: 0;
14+
overflow: hidden;
15+
background: #fff;
16+
width: 100%;
17+
height: 100%
18+
}
19+
20+
#map {
21+
position: absolute;
22+
width: 100%;
23+
height: 100%;
24+
}
25+
26+
#toolbar {
27+
position: absolute;
28+
top: 50px;
29+
right: 10px;
30+
width: 300px;
31+
text-align: center;
32+
z-index: 100;
33+
border-radius: 4px;
34+
}
35+
36+
/* 用户自定义-弹框内容样式 */
37+
#pop-content {
38+
right: 0 !important;
39+
padding-left: 20px;
40+
color: #000;
41+
word-wrap: break-word;
42+
margin-top: 10px;
43+
}
44+
</style>
45+
</head>
46+
47+
<body>
48+
<div id="toolbar" class="panel panel-primary">
49+
<div class='panel-heading'>
50+
<h5 class='panel-title text-center' data-i18n="resources.title_DatasourceInfo"></h5>
51+
</div>
52+
<div class='panel-body content'>
53+
<div class='panel'>
54+
<div class='input-group'>
55+
<span class='input-group-addon' data-i18n="resources.text_Datasources"></span>
56+
<select id='datasourcesSelect' class='form-control'></select>
57+
</div>
58+
</div>
59+
<input type="button" class="btn btn-default" data-i18n="[value]resources.btn_query"
60+
onclick="datasourcesPrint()" />
61+
</div>
62+
</div>
63+
<div id="map"></div>
64+
<script type="text/javascript" include="infoWindow" src="../../dist/classic/include-classic.js"></script>
65+
<script>
66+
let host = window.isLocal ? window.server : "https://iserver.supermap.io";
67+
let map, layer,datasourcesSelect,
68+
url1 = host + "/iserver/services/map-world/rest/maps/World",
69+
url2 = host + "/iserver/services/data-world/rest/data";
70+
71+
init()
72+
function init() {
73+
map = new SuperMap.Map("map", {
74+
controls: [
75+
new SuperMap.Control.Zoom(),
76+
new SuperMap.Control.Navigation({
77+
dragPanOptions: {
78+
enableKinetic: true
79+
}
80+
})]
81+
});
82+
layer = new SuperMap.Layer.TiledDynamicRESTLayer("World", url1, {
83+
transparent: true, cacheEnabled: true
84+
}, { maxResolution: "auto" });
85+
layer.events.on({ "layerInitialized": addLayer });
86+
//初始化popup类
87+
markerPop = new SuperMap.InfoWindow(
88+
"marker",
89+
resources.text_featureInfo
90+
);
91+
}
92+
93+
function addLayer() {
94+
map.addLayers([layer]);
95+
map.setCenter(new SuperMap.LonLat(0, 0), 0);
96+
dataSourcesService();
97+
}
98+
99+
function dataSourcesService() {
100+
new SuperMap.REST.DatasourceService(url2).getDatasources(function (serviceResult) {
101+
datasourcesSelect = document.getElementById("datasourcesSelect");
102+
const datasourceNames = serviceResult.result.datasourceNames;
103+
for (let i = 0, len = datasourceNames.length; i < len; i++) {
104+
datasourcesSelect.options[i] = new Option(datasourceNames[i], datasourceNames[i]);
105+
}
106+
107+
});
108+
}
109+
110+
//打印数据源信息
111+
function datasourcesPrint() {
112+
const datasourceName = datasourcesSelect.value;
113+
new SuperMap.REST.DatasourceService(url2).getDatasource(datasourceName, function (serviceResult) {
114+
markerPop.hide();
115+
markerPop.titleBox = true;
116+
markerPop.contentSize = new SuperMap.Size(240, 150);
117+
markerPop.render();
118+
markerPop.setContentHTML(null, '<div id="pop-content">' + "(" + resources.text_datasourceInfoPrint + ")" + "<br>" +
119+
"coordUnit:" + JSON.stringify(serviceResult.result.datasourceInfo.coordUnit, null, 2) + "<br>" +
120+
"description:" + JSON.stringify(serviceResult.result.datasourceInfo.description, null, 2) + "<br>" +
121+
"distanceUnit:" + JSON.stringify(serviceResult.result.datasourceInfo.distanceUnit, null, 2) + "<br>" +
122+
"engineType:" + JSON.stringify(serviceResult.result.datasourceInfo.engineType, null, 2) + "<br>" +
123+
"prjCoordSys:" + "(...)" + "<br>" +
124+
"name:" + JSON.stringify(serviceResult.result.datasourceInfo.name, null, 2) + "<br></div>")
125+
markerPop.setLonLat(map.getCenter(), { x: 0, y: 0 });
126+
//添加弹窗到map图层
127+
map.addPopup(markerPop)
128+
});
129+
}
130+
131+
// Feature取消选中事件响应
132+
function onFeatureUnselect() {
133+
markerPop.destroy();
134+
}
135+
136+
</script>
137+
</body>
138+
139+
</html>

0 commit comments

Comments
 (0)