ConfigManagertest1.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. var configXML='<Configuration>' +
  28. '<defaultConfigName></defaultConfigName>' +
  29. '<map>'+
  30. '<maptype>2D</maptype>'+
  31. '<initialextent></initialextent>'+
  32. '<WebServiceURL>https://10.101.35.50/zhwjWebservice/Webservice/WebService.asmx</WebServiceURL>'+
  33. '<MYQueryLayer>https://10.101.35.46:6443/arcgis/rest/services/zhwj/MapServer</MYQueryLayer>'+
  34. '<basemaps3D>'+
  35. ' <Layer type="scene" label="建筑物" visible="true" >https://10.101.35.50:5443/i3s_svc/baimo/SceneServer/layers/0</Layer>' +
  36. ' <Layer type="scene" label="水箱" visible="false" >https://10.101.35.50:5443/i3s_svc/sx0629/SceneServer/layers/0</Layer>' +
  37. ' <Layer type="tiled" label="地面" visible="true" >https://10.101.35.50/arcgis/rest/services/zhwjlm4/MapServer</Layer>' +
  38. ' <Layer type="dynamic" label="动态数据" visible="true" >https://10.101.35.50/arcgis/rest/services/zhwj/MapServer</Layer>' +
  39. ' <Layer type="density" label="density_1" visible="true" > https://10.101.35.50/arcgis/rest/services/zhwj/MapServer</Layer>'+
  40. '</basemaps3D>'+
  41. '<containExtraLayer>0</containExtraLayer>'+
  42. '<portalItemId>76eb30639aff4e70bbecfd74a93226c4</portalItemId>' +
  43. ' <fullextent>-10696.497436769,267.175033188,13967.733349092,9822.324974442</fullextent>' +
  44. ' <extent1>-17221.816,-5450.66,-15189.445,-4297.402</extent1>' +
  45. ' <extent2>-25930.782,-10527.042,-5599.259,647.995</extent2>' +
  46. ' <extent3>-89836.648,-56485.216,70797.201,31738.557</extent3>' +
  47. ' <viewxmax>237744.475488951</viewxmax>' +
  48. ' <viewxmin>-237744.475488951</viewxmin>' +
  49. ' <viewymax>76538.81974430617</viewymax>' +
  50. ' <viewymin>-76538.81974430617</viewymin>' +
  51. ' <basemaps>' +
  52. ' <Layer type="tiled" label="基础数据" visible="true" >https://10.101.35.50/arcgis/rest/services/zhwjlm4/MapServer</Layer>' +
  53. ' <Layer type="dynamic" label="动态数据" visible="true" >https://10.101.35.50/arcgis/rest/services/zhwj/MapServer</Layer>' +
  54. ' <Layer type="density" label="density_1" visible="true" >https://10.101.35.50/arcgis/rest/services/zhwj/MapServer</Layer>' +
  55. ' </basemaps>'+
  56. '</map>'+
  57. '</Configuration>';
  58. function GetConfigData(){
  59. xmlUtil = new XMLUtil();
  60. //xmlDoc = xmlUtil.loadXmlFromFile("config/config_local.xml");
  61. xmlDoc = xmlUtil.loadXML(configXML);
  62. }
  63. function GetConfigValueByTagName(tagName)
  64. {
  65. if(isEmptyValue(xmlUtil))
  66. GetConfigData();
  67. var configNode = xmlDoc.getElementsByTagName(tagName);
  68. var stringUrl = xmlUtil.getNodeValue(configNode[0]);
  69. return stringUrl;
  70. }
  71. function getRootPath_web() {
  72. //获取当前网址,如: http://localhost:8083/uimcardprj/share/meun.jsp
  73. var curWwwPath = window.document.location.href;
  74. //获取主机地址之后的目录,如: uimcardprj/share/meun.jsp
  75. var pathName = window.document.location.pathname;
  76. var pos = curWwwPath.indexOf(pathName);
  77. //获取主机地址,如: http://localhost:8083
  78. var localhostPaht = curWwwPath.substring(0, pos);
  79. //获取带"/"的项目名,如:/uimcardprj
  80. var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);
  81. return (localhostPaht + projectName);
  82. }
  83. function getRootPath_dc() {
  84. var pathName = window.location.pathname.substring(1);
  85. var webName = pathName == '' ? '' : pathName.substring(0, pathName.indexOf('/'));
  86. if (webName == "") {
  87. return window.location.protocol + '//' + window.location.host;
  88. }
  89. else {
  90. return window.location.protocol + '//' + window.location.host + '/' + webName;
  91. }
  92. }
  93. function GetConfigDataByName(nodeName) {
  94. var nodeXml = xmlDoc.getElementsByTagName(nodeName);
  95. var nodeValue = xmlUtil.getNodeValue(nodeXml[0]);
  96. return nodeValue;
  97. }