query_datasourceInfo.html 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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_DatasourceInfo"></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_DatasourceInfo"></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. <input type="button" class="btn btn-default" data-i18n="[value]resources.btn_query"
  55. onclick="datasourcesPrint()" />
  56. </div>
  57. </div>
  58. <div id="map"></div>
  59. <script type="text/javascript" include="infoWindow" src="../../dist/classic/include-classic.js"></script>
  60. <script>
  61. let host = window.isLocal ? window.server : "https://iserver.supermap.io";
  62. let map, layer,datasourcesSelect,
  63. url1 = host + "/iserver/services/map-world/rest/maps/World",
  64. url2 = host + "/iserver/services/data-world/rest/data";
  65. init()
  66. function init() {
  67. map = new SuperMap.Map("map", {
  68. controls: [
  69. new SuperMap.Control.Zoom(),
  70. new SuperMap.Control.Navigation({
  71. dragPanOptions: {
  72. enableKinetic: true
  73. }
  74. })]
  75. });
  76. layer = new SuperMap.Layer.TiledDynamicRESTLayer("World", url1, {
  77. transparent: true, cacheEnabled: true
  78. }, { maxResolution: "auto" });
  79. layer.events.on({ "layerInitialized": addLayer });
  80. //初始化popup类
  81. markerPop = new SuperMap.InfoWindow(
  82. "marker",
  83. resources.text_featureInfo
  84. );
  85. }
  86. function addLayer() {
  87. map.addLayers([layer]);
  88. map.setCenter(new SuperMap.LonLat(0, 0), 0);
  89. dataSourcesService();
  90. }
  91. function dataSourcesService() {
  92. new SuperMap.REST.DatasourceService(url2).getDatasources(function (serviceResult) {
  93. datasourcesSelect = document.getElementById("datasourcesSelect");
  94. const datasourceNames = serviceResult.result.datasourceNames;
  95. for (let i = 0, len = datasourceNames.length; i < len; i++) {
  96. datasourcesSelect.options[i] = new Option(datasourceNames[i], datasourceNames[i]);
  97. }
  98. });
  99. }
  100. //打印数据源信息
  101. function datasourcesPrint() {
  102. const datasourceName = datasourcesSelect.value;
  103. new SuperMap.REST.DatasourceService(url2).getDatasource(datasourceName, function (serviceResult) {
  104. markerPop.hide();
  105. markerPop.titleBox = true;
  106. markerPop.contentSize = new SuperMap.Size(240, 150);
  107. markerPop.render();
  108. markerPop.setContentHTML(null, '<div id="pop-content">' + "(" + resources.text_datasourceInfoPrint + ")" + "<br>" +
  109. "coordUnit:" + JSON.stringify(serviceResult.result.datasourceInfo.coordUnit, null, 2) + "<br>" +
  110. "description:" + JSON.stringify(serviceResult.result.datasourceInfo.description, null, 2) + "<br>" +
  111. "distanceUnit:" + JSON.stringify(serviceResult.result.datasourceInfo.distanceUnit, null, 2) + "<br>" +
  112. "engineType:" + JSON.stringify(serviceResult.result.datasourceInfo.engineType, null, 2) + "<br>" +
  113. "prjCoordSys:" + "(...)" + "<br>" +
  114. "name:" + JSON.stringify(serviceResult.result.datasourceInfo.name, null, 2) + "<br></div>")
  115. markerPop.setLonLat(map.getCenter(), { x: 0, y: 0 });
  116. //添加弹窗到map图层
  117. map.addPopup(markerPop)
  118. });
  119. }
  120. // Feature取消选中事件响应
  121. function onFeatureUnselect() {
  122. markerPop.destroy();
  123. }
  124. </script>
  125. </body>
  126. </html>