include-classic.js 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /* Copyright© 2000 - 2021 SuperMap Software Co.Ltd. All rights reserved.
  2. * This program are made available under the terms of the Apache License, Version 2.0
  3. * which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
  4. (function () {
  5. var r = new RegExp("(^|(.*?\\/))(include-classic\.js)(\\?|$)"),
  6. s = document.getElementsByTagName('script'),
  7. targetScript;
  8. for (var i = 0; i < s.length; i++) {
  9. var src = s[i].getAttribute('src');
  10. if (src) {
  11. var m = src.match(r);
  12. if (m) {
  13. targetScript = s[i];
  14. break;
  15. }
  16. }
  17. }
  18. function inputScript(url) {
  19. var script = '<script type="text/javascript" src="' + url + '"><' + '/script>';
  20. document.writeln(script);
  21. }
  22. function inputCSS(url) {
  23. var css = '<link rel="stylesheet" href="' + url + '">';
  24. document.writeln(css);
  25. }
  26. function inArray(arr, item) {
  27. for (i in arr) {
  28. if (arr[i] == item) {
  29. return true;
  30. }
  31. }
  32. return false;
  33. }
  34. function supportES6() {
  35. var code = "'use strict'; class Foo {}; class Bar extends Foo {};";
  36. try {
  37. (new Function(code))();
  38. } catch (err) {
  39. return false;
  40. }
  41. if (!Array.from) {
  42. return false;
  43. }
  44. return true;
  45. }
  46. //加载类库资源文件
  47. function load() {
  48. var includes = (targetScript.getAttribute('include') || "").split(",");
  49. var excludes = (targetScript.getAttribute('exclude') || "").split(",");
  50. if (!inArray(excludes, 'iclient8c')) {
  51. if (!inArray(includes, 'iclient8c-plot')) {
  52. window.excludePlot = true;
  53. }
  54. inputScript("https://iclient.supermap.io/web/libs/iclient8c/libs/SuperMap.Include.js");
  55. }
  56. if (inArray(includes, 'mapv')) {
  57. inputScript("https://cdn.jsdelivr.net/npm/mapv@2.0.56/build/mapv.min.js");
  58. }
  59. if (inArray(includes, 'echarts')) {
  60. inputScript('https://cdn.jsdelivr.net/npm/echarts@4.9.0/dist/echarts.min.js');
  61. }
  62. if (inArray(includes, 'nanoscroller')) {
  63. inputCSS("https://iclient.supermap.io/web/libs/iclient8c/examples/css/nanoscroller.css");
  64. inputScript("https://iclient.supermap.io/web/libs/iclient8c/examples/js/jquery.nanoscroller.min.js");
  65. }
  66. if (inArray(includes, 'infoWindow')) {
  67. inputCSS("https://iclient.supermap.io/web/libs/iclient8c/examples/js/plugins/infoWindow/infoWindow.css");
  68. inputScript("https://iclient.supermap.io/web/libs/iclient8c/examples/js/plugins/infoWindow/InfoWindow.js");
  69. }
  70. if (inArray(includes, 'heatmapColorCSS')) {
  71. inputCSS("https://iclient.supermap.io/web/libs/iclient8c/examples/css/heatmap.css");
  72. }
  73. if (!inArray(excludes, 'iclient-classic')) {
  74. if (supportES6()) {
  75. inputScript("../../dist/classic/iclient-classic-es6.min.js");
  76. } else {
  77. inputScript("../../dist/classic/iclient-classic.min.js");
  78. }
  79. }
  80. if (inArray(includes, 'tianditu')) {
  81. inputScript("https://iclient.supermap.io/web/libs/iclient8c/examples/js/layer/Tianditu.js");
  82. }
  83. if (inArray(includes, 'echarts-all')) {
  84. inputScript("https://iclient.supermap.io/web/libs/iclient8c/examples/js/echarts-all.js");
  85. }
  86. if (inArray(includes, 'baidu')) {
  87. inputScript("https://iclient.supermap.io/web/libs/iclient8c/examples/js/layer/Baidu.js");
  88. }
  89. if (inArray(includes, 'OSMBuildings-SuperMap')) {
  90. inputScript("https://iclient.supermap.io/web/libs/iclient8c/examples/js/OSMBuildings-SuperMap.js");
  91. }
  92. if (inArray(includes, 'D3WindMap')) {
  93. inputScript("https://iclient.supermap.io/web/libs/iclient8c/examples/js/D3WindMap.js");
  94. }
  95. if (inArray(includes, 'd3')) {
  96. inputScript("https://iclient.supermap.io/web/libs/iclient8c/examples/js/d3.v3.min.js");
  97. }
  98. if (inArray(includes, 'three')) {
  99. inputScript("https://iclient.supermap.io/web/libs/iclient8c/examples/js/third-party/Three/ThreeWebGL.js");
  100. inputScript("https://iclient.supermap.io/web/libs/iclient8c/examples/js/third-party/Three/ThreeExtras.js");
  101. inputScript("https://iclient.supermap.io/web/libs/iclient8c/examples/js/third-party/Three/RequestAnimationFrame.js");
  102. inputScript("https://iclient.supermap.io/web/libs/iclient8c/examples/js/third-party/Three/Detector.js");
  103. inputScript("https://iclient.supermap.io/web/libs/iclient8c/examples/js/third-party/globe.js");
  104. }
  105. if (inArray(includes, 'MapToImg')) {
  106. inputScript("https://iclient.supermap.io/web/libs/iclient8c/examples/js/MapToImg.js");
  107. }
  108. if (inArray(includes, 'Bar')) {
  109. inputScript("https://iclient.supermap.io/web/libs/iclient8c/examples/js/graph/Bar.js");
  110. }
  111. if (inArray(includes, 'Bar3D')) {
  112. inputScript("https://iclient.supermap.io/web/libs/iclient8c/examples/js/graph/Bar3D.js");
  113. }
  114. if (inArray(includes, 'Circle')) {
  115. inputScript("https://iclient.supermap.io/web/libs/iclient8c/examples/js/graph/Circle.js");
  116. }
  117. if (inArray(includes, 'Line')) {
  118. inputScript("https://iclient.supermap.io/web/libs/iclient8c/examples/js/graph/Line.js");
  119. }
  120. if (inArray(includes, 'Pie')) {
  121. inputScript("https://iclient.supermap.io/web/libs/iclient8c/examples/js/graph/Pie.js");
  122. }
  123. if (inArray(includes, 'Point')) {
  124. inputScript("https://iclient.supermap.io/web/libs/iclient8c/examples/js/graph/Point.js");
  125. }
  126. if (inArray(includes, 'Ring')) {
  127. inputScript("https://iclient.supermap.io/web/libs/iclient8c/examples/js/graph/Ring.js");
  128. }
  129. if (inArray(includes, 'style')) {
  130. inputCSS("https://iclient.supermap.io/web/libs/iclient8c/theme/default/style.css");
  131. }
  132. if (inArray(includes, 'sm-doc')) {
  133. inputCSS("https://iclient.supermap.io/web/libs/iclient8c/examples/css/sm-doc.css");
  134. }
  135. if (inArray(includes, 'LargeFormatPrints')) {
  136. inputScript("https://iclient.supermap.io/web/libs/iclient8c/examples/js/LargeFormatPrints.js");
  137. }
  138. if (inArray(includes, 'PlottingPanel')) {
  139. inputScript("https://iclient.supermap.io/web/libs/iclient8c/examples/js/plottingPanel/PlottingPanel.Include.js");
  140. }
  141. if (inArray(includes, 'bevInclude')) {
  142. inputScript("https://iclient.supermap.io/web/libs/iclient8c/examples/js/bevInclude.js");
  143. }
  144. if (inArray(includes, 'DefaultStyleConfiguration')) {
  145. inputScript("https://iclient.supermap.io/web/libs/iclient8c/resource/Plugins/Plotting/DefaultStyleConfiguration.js");
  146. }
  147. }
  148. load();
  149. window.isLocal = false;
  150. window.server = document.location.toString().match(/file:\/\//) ? "http://localhost:8090" : document.location.protocol + "//" + document.location.host;
  151. })();