topBar.js 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. /**
  2. * [ONEMAP.M.footer]
  3. * @return {[object]}
  4. */
  5. define([
  6. 'html!templates/topBar',
  7. 'css!styles/topBar'
  8. ], function (tplLayout) {
  9. //状态模式
  10. var status = {
  11. mapModel: '2D' //地图浏览模式
  12. };
  13. function init() {
  14. setLayout();
  15. bindEvent();
  16. subscribe();
  17. };
  18. function setLayout() {
  19. $(tplLayout).appendTo($("#topBar .total-content"));
  20. //军综网关闭态势功能
  21. if (map23DConfig.netType == 2) {
  22. $("#topBar .tools-taiShi").hide();
  23. }
  24. if (!map23DConfig.jbDraw) {
  25. $("#spDraw").hide();
  26. }
  27. //地图切换
  28. require(['layoutDir/chooseBg'], function (chooseBg) {
  29. chooseBg.init();
  30. });
  31. $(".tools-contact .web a").html(onemapUrlConfig.companyWeb)
  32. $(".tools-contact .web a").attr('href', onemapUrlConfig.companyWeb)
  33. $(".tools-contact .tel span").html(onemapUrlConfig.companyTel)
  34. }
  35. function bindEvent() {
  36. //定位
  37. $(".tools-toolJumpToLatlng").unbind('click').bind('click', function () {
  38. require(['modDir/tools/toolJumpToLatlng'], function (toolJumpToLatlng) {
  39. toolJumpToLatlng.init();
  40. });
  41. ONEMAP.C.publisher.publish("locate", "topBarEvent");
  42. })
  43. //23维切换
  44. // $("#mapModelChange .bg").bind('click', function () {
  45. // if (status.mapModel === '2D') {
  46. // ONEMAP.M.sideNav.show3dMap();
  47. // status.mapModel = '3D';
  48. // $("#mapBaseLayerControl .choosemap .name-dem-control .tufu-control").hide();
  49. // } else if (status.mapModel === '3D') {
  50. // ONEMAP.M.sideNav.show2dMap();
  51. // status.mapModel = '2D';
  52. // $("#mapBaseLayerControl .choosemap .name-dem-control .tufu-control").show();
  53. // }
  54. // ONEMAP.C.publisher.publish("modalChange", "topBarEvent");
  55. // });
  56. //放大
  57. $(".tools-zoomIn").unbind('click').bind("click", function () {
  58. var center = {
  59. lng: 0,
  60. lat: 0
  61. }
  62. var zoom = 0
  63. if (map23DData.synch) {
  64. if (map23DData.display.map2D) {
  65. var center = map2DViewer.map.getCenter()
  66. var zoom = map2DViewer.map.getZoom();
  67. } else if (map23DData.display.map3D) {
  68. var center = map3DViewer.get3DViewCenter()
  69. var zoom = map3DViewer.getZoomFrom3DZoom(center.alt)
  70. }
  71. zoom = zoom + 1
  72. if (zoom > map2DViewer.map.options.maxZoom) {
  73. zoom = map2DViewer.map.options.maxZoom
  74. }
  75. map23DControl.setView({
  76. center: {
  77. lat: center.lat,
  78. lng: center.lng
  79. },
  80. zoom: zoom
  81. })
  82. } else {
  83. if (map23DData.display.map2D) {
  84. var center = map2DViewer.map.getCenter()
  85. var zoom = map2DViewer.map.getZoom();
  86. map2DViewer.setView({
  87. center: {
  88. lat: center.lat,
  89. lng: center.lng
  90. },
  91. zoom: zoom + 1
  92. })
  93. } else if (map23DData.display.map3D) {
  94. var center = map3DViewer.get3DViewCenter()
  95. var zoom = map3DViewer.getZoomFrom3DZoom(center.alt)
  96. map3DViewer.setView({
  97. center: {
  98. lat: center.lat,
  99. lng: center.lng
  100. },
  101. zoom: zoom + 1
  102. })
  103. }
  104. }
  105. });
  106. //缩小
  107. $(".tools-zoomOut").unbind('click').bind("click", function () {
  108. var center = {
  109. lng: 0,
  110. lat: 0
  111. }
  112. var zoom = 0
  113. if (map23DData.synch) {
  114. if (map23DData.display.map2D) {
  115. var center = map2DViewer.map.getCenter()
  116. var zoom = map2DViewer.map.getZoom();
  117. } else if (map23DData.display.map3D) {
  118. var center = map3DViewer.get3DViewCenter()
  119. var zoom = map3DViewer.getZoomFrom3DZoom(center.alt)
  120. }
  121. if (!zoom) {
  122. zoom = map2DViewer.map.options.minZoom + 1
  123. }
  124. zoom = zoom - 1;
  125. if (zoom < map2DViewer.map.options.minZoom) {
  126. zoom = map2DViewer.map.options.minZoom
  127. }
  128. map23DControl.setView({
  129. center: {
  130. lat: center.lat,
  131. lng: center.lng
  132. },
  133. zoom: zoom
  134. })
  135. } else {
  136. if (map23DData.display.map2D) {
  137. var center = map2DViewer.map.getCenter()
  138. var zoom = map2DViewer.map.getZoom();
  139. map2DViewer.setView({
  140. center: {
  141. lat: center.lat,
  142. lng: center.lng
  143. },
  144. zoom: zoom - 1
  145. })
  146. } else if (map23DData.display.map3D) {
  147. var center = map3DViewer.get3DViewCenter()
  148. var zoom = map3DViewer.getZoomFrom3DZoom(center.alt)
  149. if (!zoom) {
  150. zoom = 0
  151. }
  152. zoom = zoom - 1
  153. if (zoom < 0) {
  154. zoom = 0
  155. }
  156. map3DViewer.setView({
  157. center: {
  158. lat: center.lat,
  159. lng: center.lng
  160. },
  161. zoom: zoom
  162. })
  163. }
  164. }
  165. });
  166. //联系我们
  167. $(".tools-contact").bind("mouseover", function () {
  168. $(".tools-contact .bg .p").show()
  169. }).on('mouseout', function () {
  170. $(".tools-contact .bg .p").hide()
  171. }).bind('click', function () {
  172. })
  173. //开发者
  174. $(".tools-developer").on("mouseover", function () {
  175. $(".tools-developer .bg .p").show()
  176. }).on('mouseout', function () {
  177. $(".tools-developer .bg .p").hide()
  178. }).on('click', function () {
  179. if (ONEMAP.D.user.guest) {
  180. ONEMAP.C.publisher.publish({
  181. type: 'warning',
  182. message: '用户未登录,请登录后查看。'
  183. }, 'noteBar::add');
  184. return
  185. } else {
  186. if (ONEMAP.D.user.roles.indexOf('developer') == -1) {
  187. ONEMAP.C.publisher.publish({
  188. type: 'warning',
  189. message: '用户未认证为开发者,请到用户中心认证。'
  190. }, 'noteBar::add');
  191. return
  192. } else {
  193. window.open(onemapUrlConfig.developerWeb)
  194. }
  195. }
  196. })
  197. //工具
  198. require(['layoutDir/toolsBar'], function (toolsBar) {
  199. toolsBar.init();
  200. });
  201. //全屏
  202. $(".tools-fullScreen,#fullscreen .cover-content").unbind('click').bind('click', function () {
  203. require(['modDir/tools/toolFullScreen'], function (toolFullScreen) {
  204. toolFullScreen.init();
  205. });
  206. });
  207. };
  208. function fullMap(option) {
  209. if (option) {
  210. $("#topBar").fadeOut('slow')
  211. } else {
  212. $("#topBar").fadeIn('slow')
  213. }
  214. }
  215. function resetMap23dStatus(options) {
  216. if (map23DData.display.map2D) {
  217. status['mapModel'] = '2D';
  218. } else {
  219. status['mapModel'] = '3D';
  220. }
  221. }
  222. /**
  223. * 注册订阅
  224. * @type {Function}
  225. * 推送:ONEMAP.C.publisher.publish(options,'moduleName::type');
  226. * 订阅:ONEMAP.C.publisher.subscribe(layoutResize,'sideBarLayoutChange');
  227. */
  228. function subscribe() {
  229. ONEMAP.C.publisher.subscribe(fullMap, 'layout::fullMap');
  230. ONEMAP.C.publisher.subscribe(resetMap23dStatus, 'change23D');
  231. }
  232. return ONEMAP.M.topBar = {
  233. init: init
  234. };
  235. })