toolShiZi.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /**
  2. * [ONEMAP.M.toolShiZi]
  3. * @return {[object]}
  4. */
  5. define(['html!templates/tools/toolShiZi',
  6. 'css!styles/user'
  7. ],function(tplLayout){
  8. var status = {
  9. userContentShow:false,
  10. shiZi:false
  11. }
  12. function init(){
  13. unSubscribe();
  14. subscribe();
  15. bindEvents();
  16. setLayout();
  17. };
  18. function setLayout(){
  19. if(!status.shiZi){
  20. $(tplLayout).appendTo($("#wrapper"));
  21. status.shiZi = true;
  22. }
  23. if($(".tools-shiZi").hasClass("cur")){
  24. remove({ modName: "cleanMap" });
  25. }
  26. else{
  27. if(map23DData.display.map3D){
  28. $("#shiZi").addClass("active")
  29. }
  30. $(".tools-shiZi").addClass("cur");
  31. addPolyLine()
  32. ONEMAP.C.publisher.publish('1', 'jingzhi');
  33. }
  34. };
  35. function addPolyLine(){
  36. var Arr = [
  37. [map2DViewer.map.getCenter().lat,-360],
  38. [map2DViewer.map.getCenter().lat,360]
  39. ]
  40. var Brr = [
  41. [-90,map2DViewer.map.getCenter().lng],
  42. [90,map2DViewer.map.getCenter().lng]
  43. ]
  44. var a = L.polyline(Arr,{color: '#04cfed', weight: 2, opacity: 1}).addTo(map2DViewer.map);
  45. ONEMAP.D.Szguid = a._leaflet_id;
  46. var b = L.polyline(Brr,{color: '#04cfed', weight: 2, opacity: 1}).addTo(map2DViewer.map);
  47. ONEMAP.D.Szguid2 = b._leaflet_id;
  48. }
  49. function updateLatlng(){
  50. var Arr = [
  51. [map2DViewer.map.getCenter().lat,-360],
  52. [map2DViewer.map.getCenter().lat,360]
  53. ]
  54. var Brr = [
  55. [-90,map2DViewer.map.getCenter().lng],
  56. [90,map2DViewer.map.getCenter().lng]
  57. ]
  58. map2DViewer.map._layers[ONEMAP.D.Szguid].setLatLngs(Arr)
  59. map2DViewer.map._layers[ONEMAP.D.Szguid2].setLatLngs(Brr)
  60. }
  61. function remove(options){
  62. if(options.modName == "cleanMap"){
  63. $(".tools-shiZi").removeClass("cur");
  64. $("#shiZi").removeClass("active")
  65. if(map2DViewer.map._layers[ONEMAP.D.Szguid]){
  66. map2DViewer.map.removeLayer(map2DViewer.map._layers[ONEMAP.D.Szguid]);
  67. map2DViewer.map.removeLayer(map2DViewer.map._layers[ONEMAP.D.Szguid2]);
  68. }
  69. unSubscribe()
  70. ONEMAP.C.publisher.publish('0', 'jingzhi');
  71. }
  72. }
  73. function fullMap(option){
  74. // if(option){
  75. // $("#userContent").fadeOut('slow')
  76. // }else{
  77. // $("#userContent").fadeIn('slow')
  78. // }
  79. }
  80. function change23D(options){
  81. // if($(".tools-shiZi").hasClass("cur")){
  82. // } else{
  83. remove({ modName: "cleanMap" });
  84. $(".tools-shiZi").removeClass("cur")
  85. $("#shiZi").removeClass("active")
  86. // }
  87. // if(options == '2d'){
  88. // $('#userContent').removeClass('class3d');
  89. // }else{
  90. // $('#userContent').addClass('class3d');
  91. // }
  92. }
  93. function subscribe(){
  94. // ONEMAP.C.publisher.subscribe(closeLeft, 'layout::closeLeft');
  95. ONEMAP.C.publisher.subscribe(change23D,'change23D');
  96. ONEMAP.C.publisher.subscribe(fullMap, 'layout::fullMap');
  97. ONEMAP.C.publisher.subscribe(remove, 'tools:active');
  98. ONEMAP.C.publisher.subscribe(updateLatlng, 'map2DMoveIng');
  99. // ONEMAP.C.publisher.subscribe(updateLatlng, 'map2DMoveEnd');
  100. };
  101. function unSubscribe(){
  102. ONEMAP.C.publisher.unSubscribe(remove, 'tools:active');
  103. ONEMAP.C.publisher.unSubscribe(updateLatlng, 'map2DMoveIng');
  104. }
  105. function bindEvents(){
  106. };
  107. return ONEMAP.M.toolShiZi = {
  108. init:init
  109. }
  110. })