ConfigManagertest.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. function ConfigManger(configPath) {
  2. var m_configPath = "";
  3. var m_xmlDoc = null;
  4. if (configPath != null && configPath != "")
  5. m_configPath = configPath;
  6. else
  7. m_configPath = "config_local.xml";
  8. if (m_configPath == null || m_configPath == "")
  9. return null;
  10. var xmlHelper = new XmlHelper();
  11. var m_xmlDoc = xmlHelper.loadFileXml(m_configPath); //获取工具栏信息
  12. if (m_xmlDoc == null)
  13. return null;
  14. //获取配置信息
  15. this.GetConfigValue = function (keyName) {
  16. if (m_xmlDoc == null)
  17. return null;
  18. var data = m_xmlDoc.getElementsByTagName(keyName); //获得所有子节点
  19. //var value = data[0].text;
  20. var xmlHelper = new XmlHelper();
  21. var value = xmlHelper.getNodeValue(data[0]);
  22. return value;
  23. }
  24. }
  25. var xmlUtil;
  26. var xmlDoc;
  27. /*
  28. var configXML='<Configuration>' +
  29. '<defaultConfigName/>' +
  30. '<WebServiceURL>' +
  31. 'http://10.101.35.46/WJWebService/Webservice/WebService.asmx' +
  32. '</WebServiceURL>' +
  33. '<WebServiceConvertCoordinateURL>' +
  34. 'https://map.wx.shdata.com/ConvertCoordinate/Service.asmx' +
  35. '</WebServiceConvertCoordinateURL>' +
  36. '<WebServiceExtraURL>' +
  37. 'https://map.wx.shdata.com/gisservice/GISService.asmx' +
  38. '</WebServiceExtraURL>' +
  39. '<PrintTaskURL>' +
  40. 'https://utility.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task' +
  41. '</PrintTaskURL>' +
  42. '<uploadUrl>http://localhost/media/</uploadUrl>' +
  43. '<map>' +
  44. '<maptype>2D</maptype>' +
  45. '<initialextent/>' +
  46. '<!-- 3d图层 -->' +
  47. '<FeatureLayer>' +
  48. 'https://services8.arcgis.com/wUIATpkD1eTGk5lC/arcgis/rest/services/HKScene3D1_WFL1/FeatureServer/' +
  49. '</FeatureLayer>' +
  50. '<MYQueryLayer>' +
  51. 'http://map.wx.shdata.com:6080/arcgis/rest/services/citygisnew/MapServer' +
  52. '</MYQueryLayer><MYFeatureLayerLayer>http://map.wx.shdata.com:6080/arcgis/rest/services/citygisnew/FeatureServer</MYFeatureLayerLayer>' +
  53. '<MYQXFeatureLayer>' +
  54. 'http://map.wx.shdata.com:6080/arcgis/rest/services/citygisnew/FeatureServer' +
  55. '</MYQXFeatureLayer>' +
  56. '<EditLayer>' +
  57. 'http://192.168.90.97:6080/arcgis/rest/services/fy/FeatureServer' +
  58. '</EditLayer>' +
  59. '<!-- 总图层数量 -->' +
  60. '<basemaps3D>' +
  61. '<Layer type="dynamic" label="动态数据" visible="true">' +
  62. 'http://139.196.105.31:6080/arcgis/rest/services/lgmap/MapServer' +
  63. '</Layer>' +
  64. '<Layer type="scene" label="建筑物" visible="true">' +
  65. 'https://tiles.arcgis.com/tiles/wUIATpkD1eTGk5lC/arcgis/rest/services/%E4%B8%B4%E6%B8%AF%E5%BB%BA%E7%AD%91%E7%89%A9/SceneServer' +
  66. '</Layer>' +
  67. '<Layer type="vector" label="地面" visible="true">' +
  68. 'https://tiles.arcgis.com/tiles/wUIATpkD1eTGk5lC/arcgis/rest/services/%E4%B8%B4%E6%B8%AF%E5%9F%BA%E7%A1%80%E5%BA%95%E5%9B%BE1954/VectorTileServer' +
  69. '</Layer>' +
  70. '</basemaps3D>' +
  71. '<containExtraLayer>0</containExtraLayer>' +
  72. '<extraFeatureServerURL>' +
  73. 'http://120.55.160.15:6080/arcgis/rest/services/HKDATA/FeatureServer' +
  74. '</extraFeatureServerURL>' +
  75. '<!-- 虹口道路图层id -->' +
  76. '<HKRoadLayerId>2</HKRoadLayerId>' +
  77. '<HKRoadLayerName>$feature.名称</HKRoadLayerName>' +
  78. '<!-- 小区图层id -->' +
  79. '<communityLayerId>2</communityLayerId>' +
  80. '<communityLayerName>$feature.name</communityLayerName>' +
  81. '<SceneLayer>' +
  82. 'http://gisswweb.hkq.gov.hk/server/rest/services/Hosted/HKBuildingColorPlus/SceneServer' +
  83. '</SceneLayer>' +
  84. '<portalUrl>https://gisswweb.hkq.gov.hk/arcgis</portalUrl>' +
  85. '<portalItemId>76eb30639aff4e70bbecfd74a93226c4</portalItemId>' +
  86. '<fullextent>' +
  87. '-10696.497436769,267.175033188,13967.733349092,9822.324974442' +
  88. '</fullextent>' +
  89. '<extent1>-17221.816,-5450.66,-15189.445,-4297.402</extent1>' +
  90. '<extent2>-25930.782,-10527.042,-5599.259,647.995</extent2>' +
  91. '<extent3>-89836.648,-56485.216,70797.201,31738.557</extent3>' +
  92. '<viewxmax>60000</viewxmax>' +
  93. '<viewxmin>-68000</viewxmin>' +
  94. '<viewymax>85246</viewymax>' +
  95. '<viewymin>-77128</viewymin>' +
  96. '<basemaps>' +
  97. '<Layer type="tiled" label="基础数据" visible="true">' +
  98. 'http://map.wx.shdata.com:6080/arcgis/rest/services/jcsj/MapServer' +
  99. '</Layer>' +
  100. '<Layer type="dynamic" label="动态数据" visible="true">' +
  101. 'http://map.wx.shdata.com:6080/arcgis/rest/services/citygisnew/MapServer' +
  102. '</Layer>' +
  103. '</basemaps>' +
  104. '<geometryservice>' +
  105. 'http://192.168.90.97:6080/arcgis/rest/services/Utilities/Geometry/GeometryServer' +
  106. '</geometryservice>' +
  107. '<QueryLayer>' +
  108. 'http://map.wx.shdata.com:6080/arcgis/rest/services/citygisnew/MapServer' +
  109. '</QueryLayer>' +
  110. ' </map>' +
  111. '</Configuration>';
  112. */
  113. function GetConfigData(){
  114. xmlUtil = new XMLUtil();
  115. xmlDoc = xmlUtil.loadXmlFromFile("config/config_local.xml");
  116. // xmlDoc = xmlUtil.loadXML(configXML);
  117. }
  118. function GetConfigValueByTagName(tagName)
  119. {
  120. if(isEmptyValue(xmlUtil))
  121. GetConfigData();
  122. var configNode = xmlDoc.getElementsByTagName(tagName);
  123. var stringUrl = xmlUtil.getNodeValue(configNode[0]);
  124. return stringUrl;
  125. }
  126. function getRootPath_web() {
  127. //获取当前网址,如: http://localhost:8083/uimcardprj/share/meun.jsp
  128. var curWwwPath = window.document.location.href;
  129. //获取主机地址之后的目录,如: uimcardprj/share/meun.jsp
  130. var pathName = window.document.location.pathname;
  131. var pos = curWwwPath.indexOf(pathName);
  132. //获取主机地址,如: http://localhost:8083
  133. var localhostPaht = curWwwPath.substring(0, pos);
  134. //获取带"/"的项目名,如:/uimcardprj
  135. var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);
  136. return (localhostPaht + projectName);
  137. }
  138. function getRootPath_dc() {
  139. var pathName = window.location.pathname.substring(1);
  140. var webName = pathName == '' ? '' : pathName.substring(0, pathName.indexOf('/'));
  141. if (webName == "") {
  142. return window.location.protocol + '//' + window.location.host;
  143. }
  144. else {
  145. return window.location.protocol + '//' + window.location.host + '/' + webName;
  146. }
  147. }
  148. function GetConfigDataByName(nodeName) {
  149. var nodeXml = xmlDoc.getElementsByTagName(nodeName);
  150. var nodeValue = xmlUtil.getNodeValue(nodeXml[0]);
  151. return nodeValue;
  152. }