footer.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. /**
  2. * [ONEMAP.M.footer]
  3. * @return {[object]}
  4. */
  5. define([
  6. 'html!templates/footer',
  7. 'css!styles/footer'
  8. ], function (tplLayout) {
  9. var status = {
  10. curTimeModel: 'six', //six 六进制 ten 十进制
  11. curZoingNum: 3 //分度带
  12. }
  13. var modValue = {
  14. hms: true,
  15. curLatlngType: 'dfm',
  16. beforeLocationMouseMove: true,
  17. }
  18. function init() {
  19. setLayout();
  20. layoutResize();
  21. bindEvent();
  22. subscribe();
  23. // getUserLocation();
  24. };
  25. function setLayout() {
  26. $(tplLayout).appendTo($("#footer .cover-content"));
  27. $('#copyright').html(onemapUrlConfig.systemCopy);
  28. $('#footer .contact.power').html(onemapUrlConfig.powerWords);
  29. if (onemapUrlConfig.contactNum) {
  30. var nums = onemapUrlConfig.contactNum;
  31. var contactDom = '';
  32. if (nums.length == 1) {
  33. contactDom = '<a href="javascript:;">' + nums[0] + '</a>';
  34. } else {
  35. for (var i = 0; i < nums.length; i++) {
  36. if (i != nums.length - 1) {
  37. contactDom += '<a href="javascript:;">' + nums[i] + '</a>,';
  38. } else {
  39. contactDom += '<a href="javascript:;">' + nums[i] + '</a>';
  40. }
  41. }
  42. }
  43. $("#footer .contact .phoneNum").html(contactDom);
  44. }
  45. layoutResize();
  46. $(window).resize(function () {
  47. layoutResize();
  48. });
  49. updateViewHeight(map23DData.view.zoom);
  50. $(".leaflet-control-scale-line").appendTo($("#footer .footer-content .scale"));
  51. if (map23DData.display.map2D) {
  52. $('#footer').removeClass('class3d');
  53. } else {
  54. $('#footer').addClass('class3d');
  55. }
  56. if (!ONEMAP.D.isLoad) {
  57. $('#footer .feedback').remove();
  58. }
  59. }
  60. function layoutResize() {
  61. var curWindowWeight = $(window).width();
  62. if (curWindowWeight < 1250) {
  63. $("#footer").addClass('min');
  64. } else {
  65. $("#footer").removeClass('min');
  66. }
  67. }
  68. function changeLtlngShowStyle() {
  69. if (status.curTimeModel === 'six') {
  70. $("#footer #pointInfoToTen").show();
  71. $("#footer #pointInfoToSix").hide();
  72. status.curTimeModel = 'ten';
  73. } else {
  74. $("#footer #pointInfoToTen").hide();
  75. $("#footer #pointInfoToSix").show();
  76. status.curTimeModel = 'six';
  77. }
  78. }
  79. function bindEvent() {
  80. $(".data-share-link").attr("href", onemapUrlConfig.shareUrl);
  81. $(".kf-center").attr("href", onemapUrlConfig.devCenterUrl);
  82. $(".olCommu").attr("href", onemapUrlConfig.olCommuUrl);
  83. $(".hoverShow").hover(function () {
  84. $(".phoneNum").toggle();
  85. })
  86. $("#pointInfoToTen .changeType").bind('click', function () {
  87. $("#changeLatlng").toggle();
  88. })
  89. $("#changeLatlng .latlng_list li").bind('click', function () {
  90. var mid = $(this).attr('mid');
  91. if (modValue.curLatlngType != mid) {
  92. $("#pointInfoToTen .changeType").html($(this).html());
  93. $("#changeLatlng").toggle();
  94. modValue.curLatlngType = mid;
  95. if (modValue.curLatlngType == "tgoos") {
  96. status.curZoingNum = 3;
  97. map23DControl.curZoingNum = 3;
  98. } else if (modValue.curLatlngType == "sgoos") {
  99. status.curZoingNum = 6;
  100. map23DControl.curZoingNum = 6;
  101. }
  102. ONEMAP.C.publisher.publish(status.curZoingNum, 'daihao');
  103. coordinateExport();
  104. }
  105. })
  106. //定位
  107. $('#footer .iplocation').bind('click', function () {
  108. getUserLocation();
  109. })
  110. };
  111. function change23D(options) {
  112. if (options == '2d') {
  113. $('#footer').removeClass('class3d');
  114. } else {
  115. $('#footer').addClass('class3d');
  116. }
  117. }
  118. function updateViewHeight(zoom) {
  119. if (map23DData.display.map3D) {
  120. //var distance = map23DData.view.distance;
  121. $("#footer .viewHeight .curheight").html(zoom.toFixed(0) + '米');
  122. $("#footer .viewHeight").show();
  123. $("#footer .viewZoom").hide();
  124. }
  125. if (map23DData.display.map2D) {
  126. $("#footer .viewZoom .curzoom").html(zoom);
  127. $("#footer .viewHeight").hide();
  128. $("#footer .viewZoom").show();
  129. }
  130. }
  131. function updateLatlng(options) {
  132. // if (!options.lng || !options.lat) {
  133. // options = modValue.curLatlng;
  134. // }
  135. if (options && options.lng && options.lat) {
  136. modValue.curLatlng = options;
  137. } else {
  138. options = modValue.curLatlng;
  139. }
  140. //经纬度显示
  141. lat = options.lat;
  142. lng = options.lng;
  143. var obj = {
  144. lng: lng,
  145. lat: lat
  146. }
  147. coordinateExport(obj)
  148. }
  149. function upsz() {
  150. // if (!modValue.beforeLocationMouseMove)
  151. // return;
  152. //经纬度显示
  153. lat = map2DViewer.map.getCenter().lat.toFixed(6);
  154. lng = map2DViewer.map.getCenter().lng.toFixed(6);
  155. modValue.curLatlng = {
  156. lng: lng,
  157. lat: lat
  158. }
  159. var obj = {
  160. lng: lng,
  161. lat: lat
  162. }
  163. coordinateExport(obj)
  164. }
  165. function coordinateExport(obj) {
  166. var latlng = null;
  167. if (obj) {
  168. latlng = new L.latLng(obj.lat, obj.lng)
  169. $('#pointInfoToTen .goosXY').data("lng", obj.lng)
  170. $('#pointInfoToTen .goosXY').data("lat", obj.lat)
  171. } else {
  172. latlng = new L.latLng($('#pointInfoToTen .goosXY').data("lat"), $('#pointInfoToTen .goosXY').data("lng"))
  173. }
  174. var zoom = map23DData.view.zoom;
  175. if (modValue.curLatlngType == 'dfm') {
  176. var nLatlng = L.Util.formatHMS(latlng);
  177. } else if (modValue.curLatlngType == 'df') {
  178. var nLatlng = L.Util.formatHM(latlng);
  179. } else if (modValue.curLatlngType == 'd') {
  180. if (lng > 180) {
  181. lng = (lng % 180) - 180;
  182. } else if (lng < -180) {
  183. lng = 180 + (lng % 180);
  184. }
  185. lng = lng.toFixed(6);
  186. lat = lat.toFixed(6);
  187. if (lat < 0) {
  188. nLat = 'S' + lat * -1;
  189. } else {
  190. nLat = 'N' + lat;
  191. }
  192. if (lng < 0) {
  193. nLng = 'W' + lng * -1;
  194. } else {
  195. nLng = 'E' + lng;
  196. }
  197. var nLatlng = {
  198. lng: nLng,
  199. lat: nLat
  200. };
  201. } else if (modValue.curLatlngType == 'tgoos' || modValue.curLatlngType == 'sgoos') {
  202. var goosLatlong = GaussUtil.fromLatLon(latlng.lat, latlng.lng, status.curZoingNum)
  203. }
  204. if (modValue.curLatlngType == 'tgoos' || modValue.curLatlngType == 'sgoos') {
  205. $('#pointInfoToTen .goosXY').empty().append('带号:' + goosLatlong.zoneNum + '&nbsp; X:' + goosLatlong.x.toFixed(4) + ' Y:' + goosLatlong.y.toFixed(4));
  206. } else {
  207. $('#pointInfoToTen .goosXY').empty().append('经度:' + nLatlng.lng + ' 纬度:' + nLatlng.lat);
  208. }
  209. }
  210. function bian(e) {
  211. if (e == "1") {
  212. ONEMAP.C.publisher.unSubscribe(updateLatlng, 'mousemove23D');
  213. ONEMAP.C.publisher.subscribe(upsz, 'map2DMoveIng');
  214. } else {
  215. ONEMAP.C.publisher.unSubscribe(upsz, 'map2DMoveIng');
  216. ONEMAP.C.publisher.subscribe(updateLatlng, 'mousemove23D');
  217. }
  218. }
  219. function removeMouseMove() {
  220. ONEMAP.C.publisher.unSubscribe(updateLatlng, 'mousemove23D');
  221. ONEMAP.C.publisher.unSubscribe(upsz, 'map2DMoveIng');
  222. }
  223. function coordinateChage(obj) {
  224. coordinateExport(obj);
  225. }
  226. //三维回调
  227. function updateLatlng3D(msg, options) {
  228. var position = map3DViewer.screenToLatLng(options.x, options.y)
  229. updateLatlng({
  230. lng: position.lng,
  231. lat: position.lat
  232. });
  233. }
  234. //三维回调
  235. function updataDEMHeight3D(msg, options) {
  236. // var position = map3DViewer.screenToLatLng(options.x, options.y)
  237. // updateLatlng({
  238. // lng: position.lng,
  239. // lat: position.lat
  240. // });
  241. //经纬度显示
  242. var lat = options.infos.lat;
  243. //var nlat = map23DControl.formatDegree(lat);
  244. var lng = options.infos.lng;
  245. //var nlng = map23DControl.formatDegree(lng);
  246. var alt = options.infos.alt;
  247. var zoom = map3DViewer.getZoomFrom3DZoom(alt);
  248. updataDEMHeight(lat, lng, zoom);
  249. $("#footer .viewHeight .curheight").html(alt.toFixed(0) + '米');
  250. }
  251. //获取当前位置
  252. // 52定位
  253. function getUserLocation_() {
  254. $.ajax({
  255. url: onemapUrlConfig.getUserLocation,
  256. type: 'get',
  257. dataType: 'json',
  258. })
  259. .done(function (data) {
  260. map23DControl.setView({
  261. center: {
  262. lat: data.latitude,
  263. lng: data.longitude
  264. },
  265. zoom: 12
  266. })
  267. })
  268. .fail(function () {
  269. console.log("error");
  270. })
  271. .always(function () {
  272. console.log("complete");
  273. });
  274. }
  275. // qq定位
  276. function getUserLocation() {
  277. var geolocation = new qq.maps.Geolocation("RUZBZ-7KZCU-CUMVO-4F62L-BOSHJ-EHFVC", "yiqing");
  278. var options = {
  279. timeout: 8000
  280. };
  281. function showPosition(position) {
  282. position = qqmapTowgs84(position.lng, position.lat)
  283. ONEMAP.D.globalSettingData.baseMap2D.center.lat = position.lat
  284. ONEMAP.D.globalSettingData.baseMap2D.center.lng = position.lng
  285. setTimeout(function () {
  286. map23DControl.setView({
  287. center: {
  288. lat: ONEMAP.D.globalSettingData.baseMap2D.center.lat,
  289. lng: ONEMAP.D.globalSettingData.baseMap2D.center.lng
  290. },
  291. zoom: 12
  292. })
  293. }, 1000);
  294. };
  295. function showErr() {
  296. $.ajax({
  297. type: "get",
  298. dataType: 'json',
  299. url: onemapUrlConfig.getQQLocationUrl + '/ws/location/v1/ip',
  300. data: {
  301. key: 'RUZBZ-7KZCU-CUMVO-4F62L-BOSHJ-EHFVC'
  302. },
  303. success: function (data) {
  304. var location = data.result.location
  305. position = qqmapTowgs84(location.lng, location.lat)
  306. ONEMAP.D.globalSettingData.baseMap2D.center.lat = position.lat
  307. ONEMAP.D.globalSettingData.baseMap2D.center.lng = position.lng
  308. setTimeout(function () {
  309. map23DControl.setView({
  310. center: {
  311. lat: ONEMAP.D.globalSettingData.baseMap2D.center.lat,
  312. lng: ONEMAP.D.globalSettingData.baseMap2D.center.lng
  313. },
  314. zoom: 12
  315. })
  316. }, 1000);
  317. }
  318. })
  319. };
  320. //获取位置信息
  321. geolocation.getLocation(showPosition, showErr, options);
  322. }
  323. /**
  324. * 注册订阅
  325. * @type {Function}
  326. * 推送:ONEMAP.C.publisher.publish(options,'moduleName::type');
  327. * 订阅:ONEMAP.C.publisher.subscribe(layoutResize,'sideBarLayoutChange');
  328. */
  329. function subscribe() {
  330. ONEMAP.C.publisher.subscribe(change23D, 'change23D');
  331. ONEMAP.C.publisher.subscribe(updateViewHeight, 'mapChange23D');
  332. ONEMAP.C.publisher.subscribe(updateLatlng, 'mousemove23D');
  333. ONEMAP.C.publisher.subscribe(bian, 'jingzhi');
  334. ONEMAP.C.publisher.subscribe(coordinateChage, 'coordinateChage');
  335. //3D
  336. PubSub.subscribe('map3D.mouseMove', updateLatlng3D);
  337. }
  338. return ONEMAP.M.footer = {
  339. init: init,
  340. removeMouseMove: removeMouseMove,
  341. coordinateChage: coordinateChage
  342. };
  343. })