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. if (!options) return
  141. //经纬度显示
  142. lat = options.lat;
  143. lng = options.lng;
  144. var obj = {
  145. lng: lng,
  146. lat: lat
  147. }
  148. coordinateExport(obj)
  149. }
  150. function upsz() {
  151. // if (!modValue.beforeLocationMouseMove)
  152. // return;
  153. //经纬度显示
  154. lat = map2DViewer.map.getCenter().lat.toFixed(6);
  155. lng = map2DViewer.map.getCenter().lng.toFixed(6);
  156. modValue.curLatlng = {
  157. lng: lng,
  158. lat: lat
  159. }
  160. var obj = {
  161. lng: lng,
  162. lat: lat
  163. }
  164. coordinateExport(obj)
  165. }
  166. function coordinateExport(obj) {
  167. var latlng = null;
  168. if (obj) {
  169. latlng = new L.latLng(obj.lat, obj.lng)
  170. $('#pointInfoToTen .goosXY').data("lng", obj.lng)
  171. $('#pointInfoToTen .goosXY').data("lat", obj.lat)
  172. } else {
  173. latlng = new L.latLng($('#pointInfoToTen .goosXY').data("lat"), $('#pointInfoToTen .goosXY').data("lng"))
  174. }
  175. var zoom = map23DData.view.zoom;
  176. if (modValue.curLatlngType == 'dfm') {
  177. var nLatlng = L.Util.formatHMS(latlng);
  178. } else if (modValue.curLatlngType == 'df') {
  179. var nLatlng = L.Util.formatHM(latlng);
  180. } else if (modValue.curLatlngType == 'd') {
  181. if (lng > 180) {
  182. lng = (lng % 180) - 180;
  183. } else if (lng < -180) {
  184. lng = 180 + (lng % 180);
  185. }
  186. lng = lng.toFixed(6);
  187. lat = lat.toFixed(6);
  188. if (lat < 0) {
  189. nLat = 'S' + lat * -1;
  190. } else {
  191. nLat = 'N' + lat;
  192. }
  193. if (lng < 0) {
  194. nLng = 'W' + lng * -1;
  195. } else {
  196. nLng = 'E' + lng;
  197. }
  198. var nLatlng = {
  199. lng: nLng,
  200. lat: nLat
  201. };
  202. } else if (modValue.curLatlngType == 'tgoos' || modValue.curLatlngType == 'sgoos') {
  203. var goosLatlong = GaussUtil.fromLatLon(latlng.lat, latlng.lng, status.curZoingNum)
  204. }
  205. if (modValue.curLatlngType == 'tgoos' || modValue.curLatlngType == 'sgoos') {
  206. $('#pointInfoToTen .goosXY').empty().append('带号:' + goosLatlong.zoneNum + '&nbsp; X:' + goosLatlong.x.toFixed(4) + ' Y:' + goosLatlong.y.toFixed(4));
  207. } else {
  208. $('#pointInfoToTen .goosXY').empty().append('经度:' + nLatlng.lng + ' 纬度:' + nLatlng.lat);
  209. }
  210. }
  211. function bian(e) {
  212. if (e == "1") {
  213. ONEMAP.C.publisher.unSubscribe(updateLatlng, 'mousemove23D');
  214. ONEMAP.C.publisher.subscribe(upsz, 'map2DMoveIng');
  215. } else {
  216. ONEMAP.C.publisher.unSubscribe(upsz, 'map2DMoveIng');
  217. ONEMAP.C.publisher.subscribe(updateLatlng, 'mousemove23D');
  218. }
  219. }
  220. function removeMouseMove() {
  221. ONEMAP.C.publisher.unSubscribe(updateLatlng, 'mousemove23D');
  222. ONEMAP.C.publisher.unSubscribe(upsz, 'map2DMoveIng');
  223. }
  224. function coordinateChage(obj) {
  225. coordinateExport(obj);
  226. }
  227. //三维回调
  228. function updateLatlng3D(msg, options) {
  229. var position = map3DViewer.screenToLatLng(options.x, options.y)
  230. updateLatlng({
  231. lng: position.lng,
  232. lat: position.lat
  233. });
  234. }
  235. //三维回调
  236. function updataDEMHeight3D(msg, options) {
  237. // var position = map3DViewer.screenToLatLng(options.x, options.y)
  238. // updateLatlng({
  239. // lng: position.lng,
  240. // lat: position.lat
  241. // });
  242. //经纬度显示
  243. var lat = options.infos.lat;
  244. //var nlat = map23DControl.formatDegree(lat);
  245. var lng = options.infos.lng;
  246. //var nlng = map23DControl.formatDegree(lng);
  247. var alt = options.infos.alt;
  248. var zoom = map3DViewer.getZoomFrom3DZoom(alt);
  249. updataDEMHeight(lat, lng, zoom);
  250. $("#footer .viewHeight .curheight").html(alt.toFixed(0) + '米');
  251. }
  252. //获取当前位置
  253. // 52定位
  254. function getUserLocation_() {
  255. $.ajax({
  256. url: onemapUrlConfig.getUserLocation,
  257. type: 'get',
  258. dataType: 'json',
  259. })
  260. .done(function (data) {
  261. map23DControl.setView({
  262. center: {
  263. lat: data.latitude,
  264. lng: data.longitude
  265. },
  266. zoom: 12
  267. })
  268. })
  269. .fail(function () {
  270. console.log("error");
  271. })
  272. .always(function () {
  273. console.log("complete");
  274. });
  275. }
  276. // qq定位
  277. function getUserLocation() {
  278. var geolocation = new qq.maps.Geolocation("RUZBZ-7KZCU-CUMVO-4F62L-BOSHJ-EHFVC", "yiqing");
  279. var options = {
  280. timeout: 8000
  281. };
  282. function showPosition(position) {
  283. position = qqmapTowgs84(position.lng, position.lat)
  284. ONEMAP.D.globalSettingData.baseMap2D.center.lat = position.lat
  285. ONEMAP.D.globalSettingData.baseMap2D.center.lng = position.lng
  286. setTimeout(function () {
  287. map23DControl.setView({
  288. center: {
  289. lat: ONEMAP.D.globalSettingData.baseMap2D.center.lat,
  290. lng: ONEMAP.D.globalSettingData.baseMap2D.center.lng
  291. },
  292. zoom: 12
  293. })
  294. }, 1000);
  295. };
  296. function showErr() {
  297. $.ajax({
  298. type: "get",
  299. dataType: 'json',
  300. url: onemapUrlConfig.getQQLocationUrl + '/ws/location/v1/ip',
  301. data: {
  302. key: 'RUZBZ-7KZCU-CUMVO-4F62L-BOSHJ-EHFVC'
  303. },
  304. success: function (data) {
  305. var location = data.result.location
  306. position = qqmapTowgs84(location.lng, location.lat)
  307. ONEMAP.D.globalSettingData.baseMap2D.center.lat = position.lat
  308. ONEMAP.D.globalSettingData.baseMap2D.center.lng = position.lng
  309. setTimeout(function () {
  310. map23DControl.setView({
  311. center: {
  312. lat: ONEMAP.D.globalSettingData.baseMap2D.center.lat,
  313. lng: ONEMAP.D.globalSettingData.baseMap2D.center.lng
  314. },
  315. zoom: 12
  316. })
  317. }, 1000);
  318. }
  319. })
  320. };
  321. //获取位置信息
  322. geolocation.getLocation(showPosition, showErr, options);
  323. }
  324. /**
  325. * 注册订阅
  326. * @type {Function}
  327. * 推送:ONEMAP.C.publisher.publish(options,'moduleName::type');
  328. * 订阅:ONEMAP.C.publisher.subscribe(layoutResize,'sideBarLayoutChange');
  329. */
  330. function subscribe() {
  331. ONEMAP.C.publisher.subscribe(change23D, 'change23D');
  332. ONEMAP.C.publisher.subscribe(updateViewHeight, 'mapChange23D');
  333. ONEMAP.C.publisher.subscribe(updateLatlng, 'mousemove23D');
  334. ONEMAP.C.publisher.subscribe(bian, 'jingzhi');
  335. ONEMAP.C.publisher.subscribe(coordinateChage, 'coordinateChage');
  336. //3D
  337. PubSub.subscribe('map3D.mouseMove', updateLatlng3D);
  338. }
  339. return ONEMAP.M.footer = {
  340. init: init,
  341. removeMouseMove: removeMouseMove,
  342. coordinateChage: coordinateChage
  343. };
  344. })