show.as 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. import com.common.ConfigUtil;
  2. import com.common.ConstUtil;
  3. import com.server.QueryAction;
  4. import com.supermap.web.actions.MapAction;
  5. import com.supermap.web.core.Feature;
  6. import com.supermap.web.core.geometry.GeoLine;
  7. import com.supermap.web.core.geometry.GeoPoint;
  8. import com.supermap.web.core.geometry.GeoRegion;
  9. import com.supermap.web.core.styles.PictureMarkerStyle;
  10. import com.supermap.web.mapping.ElementsLayer;
  11. import com.supermap.web.mapping.FeaturesLayer;
  12. import com.supermap.web.mapping.GraphicsLayer;
  13. import com.utils.CommonUtility;
  14. import com.view.VideoTitleWindow;
  15. import flash.events.Event;
  16. import flash.events.MouseEvent;
  17. import mx.controls.Alert;
  18. import mx.controls.Tree;
  19. private var featureStyle:Object;
  20. private function checkBox_click(event:Event):void
  21. {
  22. if(!featureStyle)
  23. featureStyle = new Object();
  24. var state:String = Tree(event.currentTarget).selectedItem.@STATE;
  25. var layerId:String = Tree(event.currentTarget).selectedItem.@CDID;
  26. if(layerId=="ALL")
  27. {
  28. checkAllLayer(state);
  29. return;
  30. }
  31. currSelectedLayerId = layerId;
  32. featureStyle[currSelectedLayerId] = Tree(event.currentTarget).selectedItem.@CDTB;
  33. if(state == "1")
  34. {
  35. var query:QueryAction = new QueryAction();
  36. query.queryLayer(currSelectedLayerId,QueryLayerEvent.QUERY_SUCCESS,"");
  37. }
  38. else
  39. {
  40. map.infoWindow.closeButton.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
  41. if(this.fLayer.features.length > 0)
  42. {
  43. var name:String;
  44. for(var i:int = this.fLayer.features.length - 1; i > -1; i-- in this.fLayer.features)
  45. {
  46. name = this.fLayer.features[i].name;
  47. if(name.indexOf(currSelectedLayerId) == 0)
  48. this.fLayer.removeFeature(this.fLayer.features[i]);
  49. }
  50. }
  51. }
  52. }
  53. /**
  54. * 图层权限按钮处理
  55. */
  56. private function checkAllLayer(state:String):void
  57. {
  58. if(state == "1")
  59. {
  60. // 遍历所有菜单配置
  61. var list:XMLList = menuXML.children();
  62. for each( var xmlChildren:XML in list)
  63. {
  64. if(xmlChildren.@CDID=="ALL")
  65. {
  66. continue;
  67. }
  68. xmlChildren.@STATE="1";
  69. var query:QueryAction = new QueryAction();
  70. query.queryLayer(xmlChildren.@CDID,QueryLayerEvent.QUERY_SUCCESS,"");
  71. }
  72. }
  73. else
  74. {
  75. map.infoWindow.closeButton.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
  76. if(this.fLayer.features.length > 0)
  77. {
  78. var name:String;
  79. for(var i:int = this.fLayer.features.length - 1; i > -1; i-- in this.fLayer.features)
  80. {
  81. this.fLayer.removeFeature(this.fLayer.features[i]);
  82. }
  83. clearAllCheckedMenu();
  84. }
  85. }
  86. return;
  87. }
  88. private function queryLayerSuccess(event:QueryLayerEvent):void
  89. {
  90. var obj:Object = event.data;
  91. if(obj == null)
  92. {
  93. Alert.show("查询失败!","错误");
  94. return;
  95. }
  96. var features:Array = obj.features;
  97. var layerId:String = obj.layerId;
  98. for each(var fea:Feature in features)
  99. {
  100. try
  101. {
  102. if(fea.geometry is GeoPoint)
  103. {
  104. var markerStyle:PictureMarkerStyle = new PictureMarkerStyle();
  105. markerStyle.source = featureStyle[layerId].toString();
  106. fea.style = markerStyle;
  107. }
  108. else if (fea.geometry is GeoLine)
  109. {
  110. fea.style = ConfigUtil.getPolylineStyle();
  111. }
  112. else if(fea.geometry is GeoRegion)
  113. {
  114. if(layerId == ConstUtil.L_ID_AQ_GQ)
  115. {
  116. fea.style = ConfigUtil.getPolygonStyle(0xffffff,0);
  117. }else if(layerId == ConstUtil.L_ID_BW_AQ){
  118. fea.style = ConfigUtil.getPolygonStyle(uint(0x009933),0.0,0x000000,1,0.0);
  119. }else{
  120. fea.style = ConfigUtil.getPolygonStyle();
  121. }
  122. }
  123. fea.name = layerId;
  124. fea.useHandCursor = true;
  125. fea.mouseChildren = false;
  126. fea.buttonMode = true;
  127. fea.addEventListener(MouseEvent.CLICK,featureClick);
  128. this.fLayer.addFeature(fea);
  129. }
  130. catch(err:Error)
  131. {
  132. }
  133. }
  134. }
  135. private function featureClick(event:MouseEvent):void
  136. {
  137. var fea:Feature = event.currentTarget as Feature;
  138. if(fea.name == ConstUtil.L_ID_SP)
  139. {
  140. var video:VideoTitleWindow = new VideoTitleWindow();
  141. CommonUtility.showTitleWindow(video,false);
  142. video.play(fea.attributes.WJLJ);
  143. return;
  144. }
  145. map.infoWindow.label = ConfigUtil.getMapLayerLabel(fea.name);
  146. map.infoWindow.setStyle("backgroundColor",0xFF1A96C8);
  147. map.infoWindow.infoWindowLabel.setStyle('color', 0xffffff);
  148. map.infoWindow.infoWindowLabel.setStyle('fontFamily', "华文新魏");
  149. map.infoWindow.infoWindowLabel.setStyle('fontSize', "16");
  150. this.showInfoGrid(fea);
  151. // map.infoWindow.content = this.getInfoWinGrid(fea.attributes.ID,fea.name,fea.attributes);
  152. // map.infoWindow.label = ConfigUtil.getMapLayerLabel(fea.name);
  153. // map.infoWindow.setStyle("backgroundColor",0xFF1A96C8);
  154. // map.infoWindow.infoWindowLabel.setStyle('color', 0xffffff);
  155. // map.infoWindow.infoWindowLabel.setStyle('fontFamily', "华文新魏");
  156. // map.infoWindow.infoWindowLabel.setStyle('fontSize', "16");
  157. // map.infoWindow.show(fea.geometry.center);
  158. }
  159. private function queryLayerFault(event:QueryLayerEvent):void
  160. {
  161. //Alert.show("查询失败!","错误");
  162. }
  163. /**
  164. * clear FeatureLayer GraphicsLayer ElementLayer
  165. * */
  166. public function clearAllTempLayer():void
  167. {
  168. var mapAction:MapAction = this.map.action;
  169. map.action = null;
  170. map.action = mapAction;
  171. map.infoWindow.closeButton.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
  172. // detailCt.show=false;
  173. for each(var obj:Object in this.map.layers)
  174. {
  175. if(obj is GraphicsLayer)
  176. (obj as GraphicsLayer).graphics.clear();
  177. else if(obj is FeaturesLayer)
  178. (obj as FeaturesLayer).clear();
  179. else if(obj is ElementsLayer)
  180. (obj as ElementsLayer).clear();
  181. }
  182. clearAllCheckedMenu();
  183. }
  184. public function clearAllCheckedMenu():void
  185. {
  186. var list:XMLList = menuXML.children();
  187. for each( var xmlChildren:XML in list)
  188. {
  189. xmlChildren.@STATE = "0";
  190. }
  191. }