query_datasetInfo.html 6.2 KB

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