testInfo.js 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. /**
  2. * [ONEMAP.M.projectController]
  3. * @return {[object]}
  4. */
  5. define(function(tplLayout) {
  6. /**
  7. * 初始化并订阅事件
  8. * @return {[type]} [description]
  9. */
  10. /**
  11. * 测试数据
  12. */
  13. var mn_data = {
  14. "guid": "",
  15. "initial_zoom": 5,
  16. "center_lat": 31.0331660206555,
  17. "center_lon": 107.20230990329375,
  18. "max-zoom": 15,
  19. "min-zoom": 1,
  20. "zoom": 5,
  21. "name": ""
  22. }
  23. /**
  24. * 模块数据 用于数据存储和外部调用
  25. * @type {Object}
  26. * 数据存放
  27. */
  28. var modValue = {
  29. options : {
  30. page: 1, //页数
  31. pageSize: 24, //每页条数
  32. searchType: 'byPage', //搜索类型
  33. searchKeyWord: '', //搜索关键字
  34. searchId: 0, //搜索ID
  35. theme: null, //分类
  36. region: '', //当前区域 0 全球
  37. area: ''
  38. },
  39. guidGroup:{
  40. },
  41. //查询数据集合
  42. thematicDataResult:null,
  43. //专题图分类
  44. thematicCategory:[],
  45. DOMid:null,
  46. ids:[]
  47. }
  48. function init(dm) {
  49. if (!status.initialized) {
  50. subscribe();
  51. bindEvent();
  52. status.initialized = true;
  53. }
  54. mn_data.guid = dm.next().attr("guid");
  55. mn_data.name = dm.next().html();
  56. if(dm.is(':checked')){
  57. addLayer(mn_data); // 添加图层
  58. var options = {
  59. action: "add",
  60. DOM:{
  61. guid: modValue.currentOverLayerGuid,
  62. type: "layer",
  63. name: mn_data.name,
  64. },
  65. mod: "test",
  66. testLayerID: mn_data.guid
  67. }
  68. dm.addClass(options.DOM.guid);
  69. modValue.DOMid = ONEMAP.M.myLayers.myLayerControl(options); // 添加信息到“我的图层”
  70. // modValue.ids.push([modValue.DOMid,options.DOM.guid]);
  71. // //console.log(modValue.DOMid);
  72. ONEMAP.C.publisher.subscribe(layerAction, options.DOM.guid);
  73. }
  74. else{
  75. // 从上部移除我的图层中的对应节点
  76. var getClass = dm.attr("class");
  77. var rmvClass = "." + getClass;
  78. $(rmvClass).removeAttr("checked"); // 移除选中状态
  79. var testData = $(rmvClass).eq(1).next().next().attr("guid");
  80. // //console.log(testData);
  81. var options = {
  82. action: "remove",
  83. DOMid: modValue.currentOverLayerGuid
  84. }
  85. removeLayer(testData);
  86. ONEMAP.M.myLayers.myLayerControl(options); // 移除数据层
  87. dm.removeClass(getClass); // 移除上部对应class
  88. ONEMAP.M.layerControlMenu.checkLayerNull();
  89. }
  90. }
  91. function bindEvent(){
  92. }
  93. /**
  94. * 设置界面
  95. */
  96. function setLayout() {
  97. }
  98. function layoutResize() {
  99. }
  100. // 监听图层操作动作
  101. function layerAction(options){
  102. //console.log(options);
  103. //console.log(modValue.ids);
  104. if(options.action == "remove"){
  105. //console.log("remove");
  106. removeLayer(options.guid);
  107. }
  108. else if(options.action == "opacity"){
  109. var opt = options.options.opacity;
  110. setOpacity(options.guid,opt);
  111. }
  112. else if(options.action == "up" || options.action == "down"){
  113. ONEMAP.M.myLayerActions.changeFloor();
  114. }
  115. }
  116. // 更改层级
  117. function changeFloor(){
  118. var li = $("#layerControlMenu .myLayers .mn-content li");
  119. var layer = $("#mapHolder #map2DWrap .leaflet-layer");
  120. var liLength = li.length;
  121. var zidArr = new Array();
  122. for(var i=0;i<liLength;i++){
  123. zidArr.push(li.eq(i).attr("zid"));
  124. for(var j=0;j<layer.length;j++){
  125. if(layer.eq(j).attr("zid") == zidArr[i]){
  126. layer.eq(j).css("z-index",layer.length-i);
  127. }
  128. }
  129. }
  130. }
  131. // 设置透明度
  132. function setOpacity(zid,opt){
  133. map23DControl.tileLayer({
  134. action: 'update',
  135. guid: zid,
  136. layer: {
  137. opacity: opt
  138. }
  139. })
  140. }
  141. // 检查我的图层是否为空
  142. function checkLayerNull(){
  143. // 我的图层暂无数据时
  144. if(typeof($("#layerControlMenu .myLayers .mn-content li").eq(0).html()) == "undefined"){
  145. $("#layerControlMenu .mn-content p.tip-none").show();
  146. }
  147. else{
  148. $("#layerControlMenu .mn-content p.tip-none").hide();
  149. }
  150. }
  151. // 添加图层
  152. function addLayer(data){
  153. $("#layerControlMenu .mn-content p.tip-none").hide();
  154. //添加到23D地图上
  155. modValue.currentOverLayerGuid = map23DControl.tileLayer({
  156. action: 'add',
  157. layer: {
  158. url2D: onemapUrlConfig.thematicTileUrl + '/' + data.guid + '?l={z}&x={x}&y={y}',
  159. url3D: onemapUrlConfig.thematicTileUrl + '/' + data.guid + '?l={z}&x={x}&y={y}',
  160. //url3D: onemapUrlConfig.thematicTileFo3DUrl + '/' + data.guid + '?z=%d&x=%d&y=%d',
  161. minZoom: data['min_zoom'],
  162. maxZoom: data['max_zoom'],
  163. maxNativeZoom: data['max_zoom'],
  164. attribution: '',
  165. opacity: 1,
  166. imageType: 'png',
  167. name:data.name,
  168. guid:data.guid
  169. }
  170. })
  171. map23DControl.setView({
  172. center: {
  173. lat: data['center_lat'],
  174. lng: data['center_lon']
  175. },
  176. zoom: data['zoom']
  177. })
  178. map2DViewer.map.setZoomScope(data['min_zoom'],data['max_zoom']);
  179. }
  180. // 移除图层
  181. function removeLayer(data){
  182. if (data) {
  183. modValue.thematicControlHtml.remove();
  184. map23DControl.tileLayer({
  185. action: 'remove',
  186. guid: data
  187. })
  188. data = null;
  189. // map2DViewer.map.removeControl(overLayerOpacityControl);
  190. overLayerOpacityControl = null;
  191. }
  192. ONEMAP.D.overLayerCount--;
  193. if (ONEMAP.D.overLayerCount == 0) {
  194. map2DViewer.map.setZoomScope(1, 19);
  195. }
  196. }
  197. // 更改层级
  198. function changeFloor(){
  199. var li = $("#layerControlMenu .myLayers .mn-content li");
  200. var layer = $("#mapHolder #map2DWrap .leaflet-layer");
  201. var liLength = li.length;
  202. var zidArr = new Array();
  203. for(var i=0;i<liLength;i++){
  204. zidArr.push(li.eq(i).attr("zid"));
  205. for(var j=0;j<layer.length;j++){
  206. if(layer.eq(j).attr("zid") == zidArr[i]){
  207. layer.eq(j).css("z-index",layer.length-i);
  208. }
  209. }
  210. }
  211. }
  212. /**
  213. * 注册订阅
  214. * @type {Function}
  215. * 推送:ONEMAP.C.publisher.publish(options,'moduleName::type');
  216. * 订阅:ONEMAP.C.publisher.subscribe(layoutResize,'sideBarLayoutChange');
  217. */
  218. function subscribe() {
  219. ONEMAP.C.publisher.subscribe(layoutResize, 'menuListClick');
  220. // ONEMAP.C.publisher.subscribe(remove, 'cleanMap');
  221. }
  222. /**
  223. * 取消订阅
  224. * @type {Function}
  225. * 取消订阅:ONEMAP.C.publisher.unSubscribe(layoutResize,'sideBarLayoutChange');
  226. */
  227. function unSubscribe() {
  228. }
  229. return ONEMAP.M.testInfo = {
  230. init: init
  231. }
  232. });