atlasList.js 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198
  1. /**
  2. * @fileoverview 专题图 模块
  3. * @author Song.Huang
  4. * @version 1.0.0
  5. */
  6. define([
  7. 'html!templates/atlas/atlasList',
  8. 'modDir/service/regionSearch',
  9. 'css!styles/atlas/atlasList'
  10. ], function(tplLayout,regionSearchF) {
  11. /**
  12. * 模块数据 用于数据存储和外部调用
  13. * @type {Object}
  14. * 数据存放
  15. */
  16. var modValue = {
  17. options : {
  18. page: 1, //页数
  19. pageSize: 24, //每页条数
  20. searchType: 'byPage', //搜索类型
  21. searchKeyWord: '', //搜索关键字
  22. searchId: 0, //搜索ID
  23. theme: null, //分类
  24. region: '', //当前区域 0 全球
  25. area: ''
  26. },
  27. //查询数据集合
  28. thematicDataResult:null,
  29. //专题图分类
  30. thematicCategory:[],
  31. tuisonglist:[],
  32. }
  33. /**
  34. * 状态值
  35. * @type {Boolean}
  36. * @default false
  37. * @private
  38. */
  39. var status = {
  40. initialized:false,
  41. isFirstAdd:true,
  42. showInfoData:false,
  43. showSideBar:false,
  44. fStatu:false
  45. };
  46. var overLayerOpacityControl;
  47. /**
  48. * 初始化容器
  49. * @type {Function}
  50. */
  51. function init(idx) {
  52. //未初始化,初始化布局
  53. // status.fStatu = false;
  54. // if (idx == 0) {
  55. if (!status.initialized) {
  56. //设置容器布局
  57. setLayout();
  58. bindEvent();
  59. //订阅推送
  60. subscribe();
  61. status.initialized = true;
  62. }
  63. if(idx == 1){
  64. //获取专题图分类后,默认显示第一页列表
  65. getCategory(function() {
  66. listThematicCategory();
  67. showThematic({ page: 1, searchType: 'byPage' });
  68. });
  69. }
  70. if(idx == 101){
  71. // 搜索那边点击了更多
  72. $('#thematicSearchKey').val(ONEMAP.D.user.searchKeyWord)
  73. thematicSearchHandler({
  74. keyWord: ONEMAP.D.user.searchKeyWord
  75. });
  76. }
  77. if(idx == 102){
  78. // 搜索那边过来的,不展开侧栏
  79. $('#thematicSearchKey').val(ONEMAP.D.user.searchKeyWord)
  80. thematicSearchHandler({
  81. keyWord: ONEMAP.D.user.searchKeyWord
  82. });
  83. }
  84. else{
  85. //开启侧栏
  86. ONEMAP.C.publisher.publish('handShow','layout::sideBar');
  87. status.showSideBar = true;
  88. }
  89. //设置zIndex 为最高
  90. var zIndex = ONEMAP.M.sideBar.getZIndex();
  91. $('#thematicPanel').css({zIndex:zIndex});
  92. ONEMAP.D.currentSideBarMod = 'atlas';
  93. };
  94. /**
  95. * 初始化布局
  96. */
  97. function setLayout(){
  98. $(tplLayout).appendTo($("#sideBarBody"));
  99. $("#atlasInfoDetail").appendTo('#wrapper');
  100. // $('#thematicPanel .btn-atals-labrary').css({
  101. // background:'url('+onemapUrlConfig.atlasLibraryUrl+'/images/layout/logo.png) top center'
  102. // })
  103. layoutResize();
  104. $(window).resize(function(event) {
  105. layoutResize();
  106. });
  107. $("#thematicResultsList").mCustomScrollbar({
  108. scrollInertia: 1000
  109. });
  110. };
  111. /**
  112. * 窗口布局重置
  113. * @type {Function}
  114. */
  115. function layoutResize() {
  116. $("#thematicResultsList").css({ height: $("#sideBar").height() - $('#thematicCategoryList').height() - 180 });
  117. $("#thematicResultsList").mCustomScrollbar('update');
  118. };
  119. /**
  120. * 界面事件绑定
  121. * @return {[type]} [description]
  122. */
  123. function bindEvent(){
  124. //region
  125. $('#currentRegionCheckbox').bind('click', function() {
  126. $('#currentAreaCheckbox').parent().removeClass('checked');
  127. $('#currentAreaCheckbox').removeAttr('checked');
  128. $('#thematicSearchKey').val('请输入名称');
  129. if ($(this).parent().hasClass('checked')) {
  130. modValue.options.region = '';
  131. modValue.options.page = 1;
  132. modValue.options.area = '';
  133. modValue.options.searchKeyWord = '';
  134. getPageResult(modValue.options);
  135. map2DViewer.map.off('zoomend moveend dragend', regionThematicSearch);
  136. ONEMAP.C.publisher.unSubscribe(regionThematicSearch, 'mapChange');
  137. $(this).parent().removeClass('checked');
  138. } else {
  139. map2DViewer.map.off('zoomend moveend dragend', areaThematicSearch);
  140. map2DViewer.map.on('zoomend moveend dragend', regionThematicSearch);
  141. ONEMAP.C.publisher.subscribe(regionThematicSearch, 'mapChange');
  142. modValue.options.area = '';
  143. modValue.options.searchKeyWord = '';
  144. regionThematicSearch();
  145. $(this).parent().addClass('checked');
  146. }
  147. });
  148. //bounds
  149. $('#currentAreaCheckbox').bind('click', function() {
  150. $('#currentRegionCheckbox').parent().removeClass('checked');
  151. $('#currentRegionCheckbox').removeAttr('checked');
  152. $('#thematicSearchKey').val('请输入名称');
  153. if ($(this).parent().hasClass('checked')) {
  154. modValue.options.page = 1;
  155. modValue.options.area = '';
  156. modValue.options.searchKeyWord = '';
  157. getPageResult(modValue.options);
  158. map2DViewer.map.off('zoomend moveend dragend', areaThematicSearch);
  159. $(this).parent().removeClass('checked');
  160. } else {
  161. modValue.options.region = '';
  162. map2DViewer.map.off('zoomend moveend dragend', regionThematicSearch);
  163. map2DViewer.map.on('zoomend moveend dragend', areaThematicSearch);
  164. modValue.options.region = '';
  165. modValue.options.searchKeyWord = '';
  166. areaThematicSearch();
  167. $(this).parent().addClass('checked');
  168. }
  169. });
  170. $('#thematicSearchKey').bind('focus', function() {
  171. if ($(this).val() == '请输入名称') {
  172. $(this).val('');
  173. };
  174. });
  175. $('#thematicSearchKey').bind('focusout', function() {
  176. if ($(this).val() == '') {
  177. $(this).val('请输入名称');
  178. $("#thematicCategoryList ul li.cur a").click();
  179. };
  180. });
  181. //搜索回车搜索
  182. $('#thematicSearchKey').bind('keydown', function(e) {
  183. var layerType = $("#thematicResultsList").attr("layerType");
  184. if (e.keyCode === 13) {
  185. if ($('#thematicSearchKey').val() != '' && $('#thematicSearchKey').val() != '请输入名称') {
  186. if(ONEMAP.D.user.searchType == 1){
  187. thematicSearchHandler({
  188. keyWord: $('#thematicSearchKey').val()
  189. });
  190. }
  191. else{
  192. require(['modDir/atlas/atlasCategory'], function(atlasCategory) {
  193. ONEMAP.C.publisher.publish('handShow','layout::sideBar');
  194. status.showSideBar = true;
  195. atlasCategory.init(layerType,"search");
  196. });
  197. ONEMAP.D.user.searchKeyWord = $('#thematicSearchKey').val();
  198. }
  199. }
  200. }
  201. });
  202. //按钮搜索
  203. $('#thematicSearchSubmit').bind('click', function() {
  204. var layerType = $("#thematicResultsList").attr("layerType");
  205. if ($('#thematicSearchKey').val() != '' && $('#thematicSearchKey').val() != '请输入名称') {
  206. if(ONEMAP.D.user.searchType == 1){
  207. thematicSearchHandler({
  208. keyWord: $('#thematicSearchKey').val()
  209. });
  210. }
  211. else{
  212. require(['modDir/atlas/atlasCategory'], function(atlasCategory) {
  213. ONEMAP.C.publisher.publish('handShow','layout::sideBar');
  214. status.showSideBar = true;
  215. atlasCategory.init(layerType,"search");
  216. });
  217. ONEMAP.D.user.searchKeyWord = $('#thematicSearchKey').val();
  218. }
  219. }
  220. });
  221. //海量地图库
  222. $('.btn-atals-labrary').bind('click',function(){
  223. var windowOpen = window.open();
  224. var openUrl = onemapUrlConfig.atlasLibraryUrl;
  225. if(!ONEMAP.D.user.guest){
  226. openUrl;
  227. }
  228. windowOpen.location = openUrl;
  229. })
  230. }
  231. /**
  232. * 显示指定参数的专题列表
  233. * @type {Function}
  234. * @param options {Object} {}
  235. */
  236. function showThematic(options) {
  237. ONEMAP.T.objExtend(modValue.options, options, true);
  238. getPageResult(modValue.options);
  239. };
  240. /**
  241. * 专题图查询
  242. * @param {[type]} options [description]
  243. * @return {[type]} [description]
  244. */
  245. function thematicSearchHandler(options) {
  246. // $('#thematicCategoryList .cur').removeClass('cur');
  247. // $('#thematicCategoryList li:eq(0)').addClass('cur');
  248. $('#currentAreaCheckbox').removeAttr('checked');
  249. $('#currentAreaCheckbox').parent().removeClass('checked');
  250. $('#currentRegionCheckbox').removeAttr('checked');
  251. $('#currentRegionCheckbox').parent().removeClass('checked');
  252. map2DViewer.map.off('zoomend moveend dragend', areaThematicSearch);
  253. map2DViewer.map.off('zoomend moveend dragend', regionThematicSearch);
  254. modValue.options.searchKeyWord = options.keyWord;
  255. modValue.options.searchType = 'byKeyWord';
  256. modValue.options.page = 1;
  257. // modValue.options.theme = null;
  258. modValue.options.area = '';
  259. modValue.options.region = '';
  260. getPageResult(modValue.options);
  261. };
  262. /**
  263. * 搜索分类列表内容
  264. * @return {[type]} [description]
  265. */
  266. function listThematicCategory() {
  267. $('#thematicCategoryList ul').empty();
  268. var allLi = $('<li class="cur"><a href="javascript:void(0)">全部</a></li>');
  269. allLi.appendTo($('#thematicCategoryList ul'));
  270. for (var i = 0, l = modValue.thematicCategory.length; i < l; i++) {
  271. var item = modValue.thematicCategory[i];
  272. var li = $('<li><a cid="' + item['id'] + '" href="javascript:void(0)">' + item['name'] + '</a></li>');
  273. li.appendTo($('#thematicCategoryList ul'));
  274. }
  275. layoutResize();
  276. $('#thematicCategoryList li').bind('click', function(e) {
  277. $(this).parent().find('.cur').removeClass('cur');
  278. $(this).addClass('cur');
  279. var cid = $(this).find('a').attr('cid');
  280. modValue.options.theme = cid;
  281. modValue.options.page = 1;
  282. modValue.options.searchType = 'byPage';
  283. modValue.options.searchKeyWord = '';
  284. //ie6 hack
  285. e.preventDefault();
  286. //获取对应分类的专题图
  287. getPageResult(modValue.options);
  288. });
  289. };
  290. /**
  291. * 按行政区域查询 判断当前是否有专题图显示,有的话不查询
  292. * @return {[type]} [description]
  293. */
  294. function regionThematicSearch() {
  295. if (!modValue.currentOverLayerGuid && ONEMAP.D.currentSideBarMod == 'atlas') {
  296. var regionSearch = new regionSearchF();
  297. var zoom = (map23DData.view.zoom - 3) > 0 ? (map23DData.view.zoom - 3) : 1;
  298. var center = map23DData.view.center;
  299. regionSearch.getRegionInfo({ latLng: [center.lat, center.lng], zoom: zoom }, function(data) {
  300. modValue.options.page = 1;
  301. //通过pac查询
  302. data = data.data;
  303. var region = data['level'][data['level'].length - 1]['code'];
  304. modValue.options.region = region.toString().length > 7 ? region.toString().substr(0, 7) : region;
  305. getPageResult(modValue.options);
  306. });
  307. }
  308. };
  309. /**
  310. * 按可视区域查询 判断当前是否有专题图显示,有的话不查询
  311. * @return {[type]} [description]
  312. */
  313. function areaThematicSearch() {
  314. if (!modValue.currentOverLayerGuid && ONEMAP.D.currentSideBarMod == 'atlas') {
  315. modValue.options.page = 1;
  316. //通过区域查询
  317. var mapBounds = map2DViewer.map.getBounds();
  318. if (mapBounds.getNorthEast().lng - mapBounds.getSouthWest().lng > 360) {
  319. mapBounds.getNorthEast().lng = 180;
  320. mapBounds.getSouthWest().lng = -180;
  321. }
  322. modValue.options.area = JSON.stringify([
  323. [L.Util.formatEarthLatLng(mapBounds.getSouthWest()).lng, L.Util.formatEarthLatLng(mapBounds.getSouthWest()).lat],
  324. [L.Util.formatEarthLatLng(mapBounds.getNorthEast()).lng, L.Util.formatEarthLatLng(mapBounds.getNorthEast()).lat]
  325. ]);
  326. getPageResult(modValue.options);
  327. }
  328. };
  329. /**
  330. * 根据options查询专题图
  331. * @type {Function}
  332. * @param options {Object} {page:页数,`:每页条数,searchType:查询类型 "byPage"/"byId"/"byKeyWord}
  333. * @private
  334. */
  335. function getPageResult(options) {
  336. switch (options.searchType) {
  337. case "byPage":
  338. ONEMAP.V.loading.load();
  339. byDefault(function(data) {
  340. ONEMAP.V.loading.loaded();
  341. if (!data.hasOwnProperty('map_list')) {
  342. setNotResultHtml('没有搜索到相关的信息。');
  343. $("#thematicPage").hide();
  344. } else {
  345. modValue.thematicDataResult = data;
  346. // console.log(data);
  347. createResultHtml();
  348. }
  349. });
  350. break;
  351. case "byKeyWord":
  352. ONEMAP.V.loading.load();
  353. byKeyWord(options.searchKeyWord, function(data) {
  354. ONEMAP.V.loading.loaded();
  355. if (!data.hasOwnProperty('map_list')) {
  356. setNotResultHtml('没有搜索到 ' + options.searchKeyWord + ' 的信息。');
  357. $("#thematicPage").hide();
  358. // ONEMAP.C.danfutuSearchResult = false;
  359. } else {
  360. modValue.thematicDataResult = data;
  361. ONEMAP.D.user.searchKeyWordAtlasResult = data.map_list;
  362. // ONEMAP.C.danfutuSearchResult = true;
  363. createResultHtml();
  364. }
  365. });
  366. break;
  367. }
  368. };
  369. /**
  370. * 无结果列表
  371. * @type {Function}
  372. * @param notText {String} 无结果提示文字
  373. * @returns {*}
  374. * @private
  375. */
  376. function setNotResultHtml(notText) {
  377. $("#thematicResultsList .item-list").empty();
  378. $('<p class="not-result">' + notText + '</p>').appendTo($("#thematicResultsList .item-list"));
  379. $("#thematicPage").hide();
  380. };
  381. function openNoCenterThematic(thematicData){
  382. var openUrl = onemapUrlConfig.atlasLibraryUrl+'/atlasView.html?viewType=1'+
  383. '&guid='+thematicData.guid+
  384. '&serialize='+ONEMAP.C.encryption.enCode(JSON.stringify({
  385. page: modValue.options.page, //页数
  386. pageSize: modValue.options.pageSize, //每页条数
  387. searchWord:''
  388. }));
  389. window.open(openUrl);
  390. }
  391. /**
  392. * 更新侧栏 列表和分页
  393. * @type {Function}
  394. * @private
  395. */
  396. function createResultHtml() {
  397. //清除当前加载的专题图
  398. //removeCurrentOverLayer();
  399. if (modValue.thematicDataResult && modValue.thematicDataResult.map_list.length > 0) {
  400. if(ONEMAP.D.searchFirstResult == false){
  401. $("#placePanel .thematic-content .thematic-title li:eq(0)").show().addClass("active").click();
  402. ONEMAP.D.searchFirstResult = true;
  403. }
  404. //列表
  405. var ul = $('<ul class="thematic-list"></ul>');
  406. for (var i = 0, l = modValue.thematicDataResult.map_list.length; i < l; i++) {
  407. var num = i + 1;
  408. var imgsrc = (onemapUrlConfig.thematicThumbUrl + '?production_id=' + modValue.thematicDataResult.map_list[i].guid + '&thumb_id=' + modValue.thematicDataResult.map_list[i].thumb_min_id).toString() + '&v=' + (onemapVersion.split('='))[1];
  409. var itemDataEach = modValue.thematicDataResult.map_list[i];
  410. var li = "";
  411. //判断中心点是否为0,0, 是的话加背景样式
  412. if(itemDataEach['center_lat'] == 0 && itemDataEach['center_lon'] == 0){
  413. li = $('<li><a href="javascript:void(0)" title="' + modValue.thematicDataResult.map_list[i].name + '">' +
  414. '<img src="' + imgsrc + '"/>' + '<span class="cover"></span>' + '<span class="jump"></span>' +
  415. '<span class="name">' + modValue.thematicDataResult.map_list[i].name + '</span></a></li>');
  416. }
  417. else if(ONEMAP.D.user.username && ONEMAP.D.user.username.indexOf("map_super_user")>-1){
  418. li = $('<li><a href="javascript:void(0)" title="' + modValue.thematicDataResult.map_list[i].name + '">' +
  419. '<img src="' + imgsrc + '"/>' + '<span class="cover"></span>' + '<span class="addset"></span>' +
  420. '<span class="name">' + modValue.thematicDataResult.map_list[i].name + '</span></a></li>');
  421. } else{
  422. li = $('<li><a href="javascript:void(0)" title="' + modValue.thematicDataResult.map_list[i].name + '">' +
  423. '<img src="' + imgsrc + '"/>' + '<span class="cover"></span>' +
  424. '<span class="name">' + modValue.thematicDataResult.map_list[i].name + '</span></a></li>');
  425. }
  426. $(li).find('.cover,.name').bind("click", { itemData: modValue.thematicDataResult.map_list[i] }, function(event) {
  427. var _data = event.data.itemData;
  428. if($(this).parent().hasClass('select')){
  429. //移除图层
  430. $(this).parent().removeClass('select');
  431. removeCurrentOverLayer();
  432. }else {
  433. // console.log(_data)
  434. //先移除再添加图层到地图上
  435. // if(status.isFirstAdd){
  436. // status.isFirstAdd = false;
  437. // }else{
  438. removeCurrentOverLayer();
  439. // }
  440. //判断中心点是否为0,0, 是的话弹窗显示
  441. if(_data['center_lat'] == 0 && _data['center_lon'] == 0){
  442. openNoCenterThematic(_data);
  443. return false;
  444. }
  445. var checkChongMing = ONEMAP.M.myLayerActions.checkChongMing(_data.name);
  446. var layerLength = ONEMAP.M.myLayers.checkLength();
  447. if(checkChongMing && layerLength < map23DConfig.layerMaxLength){
  448. addOverLayerToMap(_data);
  449. // console.log(_data);
  450. // 添加到我的图层
  451. var options = {
  452. action: "add",
  453. DOM:{
  454. guid: modValue.currentOverLayerGuid,
  455. type: "layer",
  456. name: _data.name,
  457. },
  458. mod: "test",
  459. testLayerID: _data.guid,
  460. layerData: _data
  461. }
  462. var guid = ONEMAP.M.myLayers.myLayerControl(options);
  463. ONEMAP.C.publisher.subscribe(layerAction, options.DOM.guid);
  464. // console.log(guid);
  465. // 查看当前图层属性
  466. $(this).parent().addClass('select');
  467. }
  468. else{
  469. ONEMAP.C.publisher.publish({ type: 'warning', message: '图层已加载或图层数量已达上限' }, 'noteBar::add');
  470. }
  471. }
  472. });
  473. $(li).find('.addset').off("click").on("click", { itemData: modValue.thematicDataResult.map_list[i] }, function(event) {
  474. event.preventDefault();
  475. if($("#atlasAddsetPop").length<=0){
  476. var atpop = $('<div id="atlasAddsetPop"></div>');
  477. atpop.html($("#atlasAddsetPopModel").html());
  478. $("body").prepend(atpop);
  479. }
  480. $("#atlasAddsetPop").addClass('active')
  481. $("#atlasAddsetPop .title").dragmove($("#atlasAddsetPop"));
  482. $("#atlasAddsetPop .title span").off("click").on("click",function(){
  483. if($(this).hasClass('juan')){
  484. $(this).removeClass('juan')
  485. $("#atlasAddsetPop .content").addClass('active');
  486. $("#atlasAddsetPop .cover-content").addClass('active');
  487. } else{
  488. $(this).addClass('juan');
  489. $("#atlasAddsetPop .content").removeClass('active');
  490. $("#atlasAddsetPop .cover-content").removeClass('active');
  491. }
  492. })
  493. var _data = event.data.itemData;
  494. var tdata = JSON.stringify(_data).replace(/\"/g, "\'");
  495. var li = $('<li dt="'+tdata+'" guid="'+_data.guid+'"><span class="name">'+_data.name+'</span><span class="del"></span></li>')
  496. if($.inArray(_data.guid,modValue.tuisonglist) == -1){
  497. $("#atlasAddsetPop .content ul").prepend(li);
  498. modValue.tuisonglist.push(_data.guid)
  499. } else{
  500. ONEMAP.C.publisher.publish({ type: 'warning', message: '您已添加过该专题图' }, 'noteBar::add');
  501. }
  502. $("#atlasAddsetPop .content ul").mCustomScrollbar({
  503. scrollInertia: 100
  504. });
  505. $("#atlasAddsetPop .content li span.del").off("click").on("click",function(){
  506. var guid = $(this).parent().attr("guid");
  507. var idx = $.inArray(guid,modValue.tuisonglist);
  508. modValue.tuisonglist.splice(idx,1);
  509. var idx = $(this).index();
  510. $(this).parent().remove();
  511. })
  512. $("#atlasAddsetPop .btns .submit").off("click").on("click",function(){
  513. $("#userContent .userInfo .moreLink .linkList li.set").click();
  514. // $("#globalSetting .panel-body .itemleft .left_header ul li").removeClass('active')
  515. $("#globalSetting .panel-body .itemleft .left_header ul li").eq(0).click()
  516. var lis = $("#atlasAddsetPop .content li");
  517. var chooseHtml = $('<ul class="chhoostListContent"></ul>');
  518. for(var i=0;i<ONEMAP.D.globalSettingData.map2DThematicCategory.length;i++){
  519. var liHtml = $('<li>'+ONEMAP.D.globalSettingData.map2DThematicCategory[i]+'</li>');
  520. $(liHtml).appendTo($(chooseHtml));
  521. }
  522. require(['modDir/user/userSetting'], function(userSetting) {
  523. console.log(lis)
  524. for(var i=0;i<lis.length;i++){
  525. var dt = lis.eq(i).attr("dt").replace(/\'/g, "\"");
  526. var ldata = JSON.parse(dt);
  527. $('#theModel .item-form .name').attr("value",ldata.name);
  528. $('#theModel .item-form .guid').attr("value",ldata.guid);
  529. $('#theModel .item-form .zoom').attr("value",ldata.initial_zoom);
  530. $('#theModel .item-form .center-lat').attr("value",ldata.center_lat);
  531. $('#theModel .item-form .center-lng').attr("value",ldata.center_lon);
  532. $('#theModel .item-form .tileLayerUrl').attr("value",onemapUrlConfig.thematicTileUrl);
  533. if(ldata.legend_id_list.length>0){
  534. $('#theModel .item-form .legend').attr("value",onemapUrlConfig.thematicThumbUrl+'?production_id='+ldata.guid+'&thumb_id='+ldata.legend_id_list[0]);
  535. } else{
  536. $('#theModel .item-form .legend').attr("value","");
  537. }
  538. $(chooseHtml).appendTo($("#theModel .item-form .category").parent());
  539. $('#map2DSettingInfoContent #dxList').append($('#theModel').html())
  540. }
  541. ONEMAP.M.setting.bindEvent();
  542. // $("#map2DSettingInfoContent .thematicModelList").mCustomScrollbar("update");
  543. // $("#map2DSettingInfoContent .thematicModelList").mCustomScrollbar("scrollTo", "bottom");
  544. //分类输入框选择
  545. $("#dxList .category").unbind('focus').bind('focus',function(e){
  546. $(this).next().show();
  547. $(this).parent().parent().parent().siblings().find('.chhoostListContent').hide();
  548. e.stopPropagation();
  549. });
  550. $("#dxList .chhoostListContent li").unbind('click').bind('click',function(){
  551. $("#dxList .chhoostListContent").hide();
  552. $(this).parent().parent().find('input').val($(this).html());
  553. });
  554. });
  555. setTimeout(function(){
  556. $("#atlasAddsetPop .content ul").html("");
  557. $("#atlasAddsetPop").removeClass('active');
  558. $("#map2DSettingInfoContent .thematicModelList").mCustomScrollbar("update");
  559. $("#map2DSettingInfoContent .thematicModelList").mCustomScrollbar("scrollTo", "bottom");
  560. },500)
  561. })
  562. $("#atlasAddsetPop .btns .cancel").off("click").on("click",function(){
  563. $("#atlasAddsetPop").removeClass('active')
  564. })
  565. })
  566. $(ul).append(li);
  567. }
  568. $("#thematicCategoryList").show();
  569. $('#thematicResultsList').find('a').unbind();
  570. $("#thematicResultsList .item-list").empty().append(ul);
  571. $("#thematicResultsList").attr("layerType",1);
  572. // // 从搜索条中读入
  573. // if(ONEMAP.D.user.searchInsert){
  574. // $("#thematicResultsList .item-list").empty().append(ONEMAP.D.user.searchKeyWordAtlasResult);
  575. // ONEMAP.D.user.searchKeyWordAtlasResult = null;
  576. // }
  577. $("#thematicResultsList").mCustomScrollbar('update');
  578. ul = null;
  579. //分页
  580. //
  581. if((modValue.options.page * modValue.options.pagesize) >= modValue.thematicDataResult.total){
  582. $("#thematicPage").hide();
  583. return;
  584. }
  585. $("#thematicPage").empty();
  586. var countPages = (parseInt(modValue.thematicDataResult.total % modValue.thematicDataResult.pagesize) > 0 ? parseInt(modValue.thematicDataResult.total / modValue.thematicDataResult.pagesize + 1) : parseInt(modValue.thematicDataResult.total / modValue.thematicDataResult.pagesize));
  587. if (countPages == 0) {
  588. countPages = 1;
  589. }
  590. var _pageJump = $('<div class="firstpage"></div>' +
  591. '<div class="uppage"></div>' +
  592. '<div class="fg"></div>' +
  593. '<div id="thematicPageJump" class="count">' +
  594. ' <span>' + modValue.thematicDataResult.page + '/' + countPages + '页</span>' +
  595. '</div>' +
  596. '<div class="fg"></div>' +
  597. '<div class="nextpage"></div>' +
  598. '<div class="endpage"></div>'
  599. );
  600. _pageJump.appendTo($("#thematicPage"));
  601. if (modValue.thematicDataResult.page == 1) {
  602. $("#thematicPage .firstpage").css("background", "url(../images/layout/page_11.png) no-repeat 7px 11px")
  603. $("#thematicPage .uppage").css("background", "url(../images/layout/page_13.png) no-repeat 10px 11px")
  604. $("#thematicPage .nextpage").css("background", "url(../images/layout/page_06ch.png) no-repeat 10px 11px")
  605. $("#thematicPage .endpage").css("background", "url(../images/layout/page_08ch.png) no-repeat 7px 11px")
  606. } else if (modValue.thematicDataResult.page == countPages) {
  607. $("#thematicPage .firstpage").css("background", "url(../images/layout/page_11ch.png) no-repeat 7px 11px")
  608. $("#thematicPage .uppage").css("background", "url(../images/layout/page_13ch.png) no-repeat 10px 11px")
  609. $("#thematicPage .nextpage").css("background", "url(../images/layout/page_06.png) no-repeat 10px 11px")
  610. $("#thematicPage .endpage").css("background", "url(../images/layout/page_08.png) no-repeat 7px 11px")
  611. } else {
  612. $("#thematicPage .firstpage").css("background", "url(../images/layout/page_11ch.png) no-repeat 7px 11px")
  613. $("#thematicPage .uppage").css("background", "url(../images/layout/page_13ch.png) no-repeat 10px 11px")
  614. $("#thematicPage .nextpage").css("background", "url(../images/layout/page_06ch.png) no-repeat 10px 11px")
  615. $("#thematicPage .endpage").css("background", "url(../images/layout/page_08ch.png) no-repeat 7px 11px")
  616. }
  617. $(".firstpage").bind("click", function() {
  618. modValue.thematicDataResult.page = 1;
  619. var op = "f";
  620. clickpage(modValue.thematicDataResult.page, countPages);
  621. $("#thematicPageJump span").html(modValue.thematicDataResult.page + "/" + countPages + "页");
  622. })
  623. $(".uppage").bind("click", function() {
  624. modValue.thematicDataResult.page--
  625. var op = "u";
  626. if (modValue.thematicDataResult.page < 1) {
  627. modValue.thematicDataResult.page = 1
  628. } else {
  629. clickpage(modValue.thematicDataResult.page, countPages);
  630. $("#thematicPageJump span").html(modValue.thematicDataResult.page + "/" + countPages + "页");
  631. }
  632. })
  633. $(".nextpage").bind("click", function() {
  634. modValue.thematicDataResult.page++
  635. var op = "n";
  636. if (modValue.thematicDataResult.page > countPages) {
  637. modValue.thematicDataResult.page = countPages
  638. } else {
  639. clickpage(modValue.thematicDataResult.page, countPages);
  640. $("#thematicPageJump span").html(modValue.thematicDataResult.page + "/" + countPages + "页");
  641. }
  642. })
  643. $(".endpage").bind("click", function() {
  644. modValue.thematicDataResult.page = countPages;
  645. var op = "e";
  646. clickpage(modValue.thematicDataResult.page, countPages);
  647. $("#thematicPageJump span").html(modValue.thematicDataResult.page + "/" + countPages + "页");
  648. })
  649. $("#thematicPageJump .page_num").bind('keydown', function(e) {
  650. if (e.keyCode === 13) {
  651. var pageJump = parseInt($("#thematicPageJump .page_num").val());
  652. if (!pageJump || pageJump > countPages) {
  653. return;
  654. } else {
  655. showThematic({ page: parseInt(pageJump),});
  656. }
  657. }
  658. });
  659. var _themtiicPageBtnGroup = $('<div class="btn-group"></div>').appendTo($("#thematicPage"));
  660. if (modValue.thematicDataResult.pagesize < modValue.thematicDataResult.total) {
  661. if (modValue.thematicDataResult.page == 1) {
  662. var abtnNext = $('<button type="button" class="btn btn2 btn-small next" pid=' + (modValue.thematicDataResult.page + 1) + '>下一页</button>');
  663. } else if (countPages == modValue.thematicDataResult.page && modValue.thematicDataResult.total > modValue.thematicDataResult.pagesize) {
  664. var abtnPrev = $('<button type="button" class="btn btn2 btn-small prev" pid=' + (modValue.thematicDataResult.page - 1) + '>上一页</button>');
  665. } else {
  666. var abtnPrev = $('<button type="button" class="btn btn2 btn-small prev" pid=' + (modValue.thematicDataResult.page - 1) + '>上一页</button>');
  667. var abtnNext = $('<button type="button" class="btn btn2 btn-small next" pid=' + (modValue.thematicDataResult.page + 1) + '>下一页</button>');
  668. }
  669. $("#thematicPage .btn").on("click", function() {
  670. showThematic({ page: parseInt($(this).attr('pid')) });
  671. });
  672. }
  673. $("#thematicPage").show();
  674. } else {
  675. $("#thematicResultsList .item-list").empty().html('<p class="not-result" style="color:#fff">单幅图暂无数据!</p>');
  676. $("#thematicPage,#placePanel .thematic-content .thematic-title li:eq(0)").hide();
  677. $("#placePanel .thematic-content .thematic-title li:eq(0)").removeClass("active");
  678. // ONEMAP.D.searchFirstResult = false;
  679. }
  680. };
  681. /**
  682. * 换页点击事件
  683. */
  684. function clickpage(op, allp) {
  685. if (op == 1) {
  686. $("#thematicPage .firstpage").css("background", "url(../images/layout/page_11.png) no-repeat 7px 11px")
  687. $("#thematicPage .uppage").css("background", "url(../images/layout/page_13.png) no-repeat 10px 11px")
  688. $("#thematicPage .nextpage").css("background", "url(../images/layout/page_06ch.png) no-repeat 10px 11px")
  689. $("#thematicPage .endpage").css("background", "url(../images/layout/page_08ch.png) no-repeat 7px 11px")
  690. } else if (op == allp) {
  691. $("#thematicPage .firstpage").css("background", "url(../images/layout/page_11ch.png) no-repeat 7px 11px")
  692. $("#thematicPage .uppage").css("background", "url(../images/layout/page_13ch.png) no-repeat 10px 11px")
  693. $("#thematicPage .nextpage").css("background", "url(../images/layout/page_06.png) no-repeat 10px 11px")
  694. $("#thematicPage .endpage").css("background", "url(../images/layout/page_08.png) no-repeat 7px 11px")
  695. } else {
  696. $("#thematicPage .firstpage").css("background", "url(../images/layout/page_11ch.png) no-repeat 7px 11px")
  697. $("#thematicPage .uppage").css("background", "url(../images/layout/page_13ch.png) no-repeat 10px 11px")
  698. $("#thematicPage .nextpage").css("background", "url(../images/layout/page_06ch.png) no-repeat 10px 11px")
  699. $("#thematicPage .endpage").css("background", "url(../images/layout/page_08ch.png) no-repeat 7px 11px")
  700. }
  701. modValue.options.page = parseInt(op);
  702. showThematic({ page: parseInt(op),searchType: 'byKeyWord'});
  703. };
  704. /**
  705. * 添加专题图层到地图层
  706. * @type {Function}
  707. * @param obj {Object} 构造好了的专题图对象
  708. * @private
  709. */
  710. function addOverLayerToMap(data) {
  711. //添加到23D地图上
  712. //如果是2D 添加透明度控件
  713. modValue.currentOverLayerGuid = map23DControl.tileLayer({
  714. action: 'add',
  715. layer: {
  716. url2D: onemapUrlConfig.thematicTileUrl + '/' + data.guid + '?l={z}&x={x}&y={y}',
  717. url3D: onemapUrlConfig.thematicTileUrl + '/' + data.guid + '?l={z}&x={x}&y={y}',
  718. //url3D: onemapUrlConfig.thematicTileFo3DUrl + '/' + data.guid + '?l={z}&x={x}&y={y}',
  719. minZoom: data['min_zoom'],
  720. maxZoom: data['max_zoom'],
  721. maxNativeZoom: data['max_zoom'],
  722. attribution: '',
  723. opacity: 1,
  724. imageType: 'png',
  725. name:data.name,
  726. guid:data.guid
  727. }
  728. })
  729. ONEMAP.D.ThematicInMapData[modValue.currentOverLayerGuid] = {
  730. 'name':data.name,
  731. 'guid':data.guid
  732. };
  733. if(status.showInfoData){
  734. getShowInfo(data);
  735. }
  736. // overLayerOpacityControl = new L.Control.LayerOpacity(
  737. // map2DViewer.layers[modValue.currentOverLayerGuid],
  738. // {
  739. // thematic_data:data,
  740. // min_zoom:data['min_zoom'],
  741. // max_zoom:data['max_zoom'],
  742. // showFavBtn:true,
  743. // atlas:true,
  744. // favCallback:addFavThematic,
  745. // getShowInfoCallback:addThematicToMap,
  746. // closeCallback:removeCurrentOverLayer
  747. // }
  748. // ).addTo(map2DViewer.map);
  749. thematicControl(
  750. map2DViewer.layers[modValue.currentOverLayerGuid], {
  751. data:data,
  752. showFavBtn: false,
  753. showFavBtn:true,
  754. atlas:true,
  755. favCallback:addFavThematic,
  756. getShowInfoCallback:addThematicToMap,
  757. closeCallback:removeCurrentOverLayer
  758. })
  759. ONEMAP.D.overLayerCount++;
  760. map2DViewer.map.setZoomScope(data['min_zoom'],data['max_zoom']);
  761. // map23DControl.setView({
  762. // center: {
  763. // lat: data['center_lat'],
  764. // lng: data['center_lon']
  765. // },
  766. // zoom: data['zoom']
  767. // })
  768. if(typeof(data['max_zoom'])!="undefined"){
  769. ONEMAP.M.myLayers.zoomActions("add",data['min_zoom'], data['max_zoom'],data['center_lat'],data['center_lon'],data['initial_zoom'],data.name);
  770. }
  771. else{
  772. ONEMAP.M.myLayers.zoomActions("add",1, 19,map23DData.view.center['lat'],map23DData.view.center['lng'],data['initial_zoom'],data.name);
  773. }
  774. };
  775. //添加三维专题图控制条
  776. function thematicControl(layer,options){
  777. modValue.thematicControlHtml = $("<div class='thematicControl'>"+
  778. "<iframe frameborder='0' class='cover-iframe'></iframe>"+
  779. "</div>");
  780. var cover_content = $("<div class='cover-content'></div>");
  781. cover_content.appendTo(modValue.thematicControlHtml);
  782. if(options.showFavBtn || !options.onlyShow){
  783. var optionsWrap = $("<div class='options-wrap'></div>");
  784. optionsWrap.appendTo(cover_content);
  785. }
  786. $("<div class='thematicName'>名称:"+options.data.name+"</div>").appendTo(cover_content);
  787. if(options.atlas){
  788. var atlasHtml = $("<a class='info_Btntd'>详情</a>");
  789. atlasHtml.appendTo(optionsWrap);
  790. atlasHtml.bind('click',function(){
  791. // console.log("6sr5");
  792. options.getShowInfoCallback(options.data);
  793. });
  794. }
  795. if(options.showFavBtn){
  796. var favBtnHtml = $("<a class='fav_abtntd'>收藏</a>");
  797. favBtnHtml.appendTo(optionsWrap);
  798. favBtnHtml.bind('click',{layer:layer},function(e){
  799. // console.log(e.data.layer);
  800. options.favCallback(e.data.layer);
  801. });
  802. }
  803. if(!options.onlyShow){
  804. var closeBtnHtml = $("<a class='close_abtntd'>关闭</a>");
  805. closeBtnHtml.appendTo(optionsWrap);
  806. closeBtnHtml.bind('click',function(){
  807. options.closeCallback();
  808. modValue.thematicControlHtml.remove();
  809. })
  810. }
  811. modValue.thematicControlHtml.appendTo($('#thematicControlContent'));
  812. };
  813. /**
  814. * 移除当前显示专题图
  815. * @private
  816. */
  817. function removeCurrentOverLayer(data) {
  818. // console.log(modValue.currentOverLayerGuid);
  819. // 删除我的图层中对应专题图
  820. var myli = $("#layerControlMenu .myLayers li");
  821. for(var i=0;i<myli.length;i++){
  822. if(myli.eq(i).attr("layer") == modValue.currentOverLayerGuid){
  823. myli.eq(i).remove();
  824. }
  825. }
  826. if(data!=undefined){
  827. status.showInfoData = false;
  828. $('#atlasInfoDetail').hide();
  829. if(typeof(data['max_zoom'])!="undefined"){
  830. ONEMAP.M.myLayers.zoomActions("remove",data['min_zoom'], data['max_zoom']);
  831. }
  832. else{
  833. ONEMAP.M.myLayers.zoomActions("remove",1, 19);
  834. }
  835. }
  836. else{
  837. }
  838. if(modValue.currentOverLayerGuid){
  839. modValue.thematicControlHtml.remove();
  840. delete ONEMAP.D.ThematicInMapData[modValue.currentOverLayerGuid];
  841. ONEMAP.D.overLayerCount--;
  842. if(ONEMAP.D.overLayerCount == 0){
  843. map2DViewer.map.setZoomScope(1,19);
  844. }
  845. map23DControl.tileLayer({
  846. action: 'remove',
  847. guid:modValue.currentOverLayerGuid
  848. })
  849. modValue.currentOverLayerGuid = null;
  850. // map2DViewer.map.removeControl(overLayerOpacityControl);
  851. overLayerOpacityControl = null;
  852. $('#thematicResultsList li.select').removeClass('select');
  853. }
  854. // 检查图层是否为空
  855. ONEMAP.M.myLayerActions.checkLayerNull();
  856. };
  857. /**
  858. * 收藏专题图
  859. * @param {[type]} layerObj [description]
  860. */
  861. function addFavThematic(layerObj) {
  862. // console.log(layerObj);
  863. require(['modDir/user/userThematic'], function(userThematic) {
  864. userThematic.addThematic(layerObj);
  865. });
  866. };
  867. /**
  868. * 显示专题图详情
  869. */
  870. function getShowInfo(data){
  871. // console.log(data);
  872. var guid = data.guid;
  873. var ajaxUrl = onemapUrlConfig.thematicDataServerUrl+'/production/metadata?production_id='+guid;
  874. ONEMAP.V.loading.load();
  875. $.ajax({
  876. type:"get",
  877. dataType:'jsonp',
  878. url:ajaxUrl,
  879. success:function(data){
  880. ONEMAP.V.loading.loaded();
  881. //添加专题图信息到地图容器中
  882. addItemToContent(data.metadata);
  883. //console.log(data.metadata);
  884. },
  885. error:function(data){
  886. ONEMAP.V.loading.loaded();
  887. ONEMAP.C.publisher.publish({type:'error',message:'获取地图数据失败!'},'noteBar::add');
  888. }
  889. });
  890. };
  891. function addItemToContent(data){
  892. $('#atlasInfoDetail').show();
  893. var zIndex = ONEMAP.M.sideBar.getZIndex();
  894. $('#atlasInfoDetail').css({zIndex:zIndex});
  895. $('#atlasInfoDetail .cover-content').empty();
  896. $('<div class="close"></div>').appendTo($('#atlasInfoDetail .cover-content'));
  897. $('<h3>'+data.map_name+'</h3>').appendTo($('#atlasInfoDetail .cover-content'));
  898. $('<p>作者: '+data.author+'</p>').appendTo($('#atlasInfoDetail .cover-content'));
  899. $('<p>创建时间: '+data.created_time+'</p>').appendTo($('#atlasInfoDetail .cover-content'));
  900. $('<p>发布者: '+data.publisher+'</p>').appendTo($('#atlasInfoDetail .cover-content'));
  901. $('<p>发布时间: '+data.publication_date+'</p>').appendTo($('#atlasInfoDetail .cover-content'));
  902. $('<p>地图来源: '+data.original_atlas+'</p>').appendTo($('#atlasInfoDetail .cover-content'));
  903. $('<p>最小缩放等级: '+data.min_zoom_level+'</p>').appendTo($('#atlasInfoDetail .cover-content'));
  904. $('<p>最大缩放等级: '+data.max_zoom_level+'</p>').appendTo($('#atlasInfoDetail .cover-content'));
  905. //$('<p>瓦片格式: '+data.image_format+'</p>').appendTo($('#atlasInfoDetail .content'));
  906. //$('<p>瓦片质量: '+data.image_quality+'</p>').appendTo($('#atlasInfoDetail .content'));
  907. $('<p>地图宽度: '+data.map_image_width+'像素</p>').appendTo($('#atlasInfoDetail .cover-content'));
  908. $('<p>地图高度: '+data.map_image_height+'像素</p>').appendTo($('#atlasInfoDetail .cover-content'));
  909. if(data.coordinate_system == 0){data.coordinate_system = '无坐标图形'}
  910. $('<p>坐标系: '+data.coordinate_system+'</p>').appendTo($('#atlasInfoDetail .cover-content'));
  911. }
  912. function addThematicToMap(data){
  913. // console.log(data);
  914. if(!status.showInfoData){
  915. status.showInfoData = true;
  916. getShowInfo(data);
  917. }else{
  918. status.showInfoData = false;
  919. $('#atlasInfoDetail').hide();
  920. }
  921. };
  922. /**
  923. * 获取专题图分类
  924. * @return {[type]} [description]
  925. */
  926. function getCategory(callback_func) {
  927. var ajaxUrl = onemapUrlConfig.thematicDataUrl + '/map/theme';
  928. ONEMAP.V.loading.load();
  929. $.ajax({
  930. url: ajaxUrl,
  931. type: 'GET',
  932. dataType: 'jsonp'
  933. })
  934. .done(function(data) {
  935. // //console.log(data);
  936. ONEMAP.V.loading.loaded();
  937. modValue.thematicCategory = data;
  938. callback_func(data);
  939. })
  940. .fail(function() {
  941. ONEMAP.V.loading.loaded();
  942. });
  943. };
  944. /**
  945. * 根据 options 参数获取 专题列表信息
  946. * @param callback_func {Function} 回调方法
  947. * @return {Object}
  948. */
  949. function byDefault(callback_func) {
  950. var ajaxUrl = onemapUrlConfig.thematicDataUrl + '/map/list' + '?types=[1,2,4]&page=' + modValue.options.page + '&pagesize=' + modValue.options.pageSize
  951. + '&region=' + modValue.options.region + '&area=' + modValue.options.area;
  952. if (modValue.options.theme != null && modValue.options.theme != 'undefined') {
  953. ajaxUrl += '&theme=' + modValue.options.theme;
  954. }
  955. var searchWord = $("#thematicSearchKey").val();
  956. if (searchWord != null && searchWord != 'undefined' && searchWord != '' && searchWord != '请输入名称') {
  957. ajaxUrl += '&search=' + searchWord;
  958. }
  959. ONEMAP.V.loading.load();
  960. $.ajax({
  961. url: ajaxUrl,
  962. type: 'GET',
  963. dataType: 'jsonp'
  964. })
  965. .done(function(data) {
  966. ONEMAP.V.loading.loaded();
  967. callback_func(data);
  968. })
  969. .fail(function() {
  970. ONEMAP.V.loading.loaded();
  971. });
  972. };
  973. /**
  974. * 关键字查询
  975. * @param keyword {String} 关键字
  976. * @param callback_func {Function} 回调方法
  977. * @return {Object}
  978. */
  979. function byKeyWord(keyword, callback_func) {
  980. var ajaxUrl = onemapUrlConfig.thematicDataUrl + '/map/list' + '?types=[1,2,4]&page=' + modValue.options.page + '&pagesize=' + modValue.options.pageSize
  981. + '&search=' + encodeURIComponent(keyword) + '&region=' + modValue.options.region + '&area=' + modValue.options.area;
  982. if (modValue.options.theme != null && modValue.options.theme != 'undefined') {
  983. ajaxUrl += '&theme=' + modValue.options.theme;
  984. }
  985. ONEMAP.V.loading.load();
  986. $.ajax({
  987. url: ajaxUrl,
  988. type: 'GET',
  989. dataType: 'jsonp'
  990. })
  991. .done(function(data) {
  992. ONEMAP.V.loading.loaded();
  993. callback_func(data);
  994. })
  995. .fail(function() {
  996. ONEMAP.V.loading.loaded();
  997. });
  998. };
  999. // 监听图层操作动作
  1000. function layerAction(options){
  1001. // console.log(options);
  1002. if(options.action == "remove"){
  1003. // console.log("remove");
  1004. removeLayer(options.guid);
  1005. }
  1006. else if(options.action == "opacity"){
  1007. var opt = options.options.opacity;
  1008. setOpacity(options.guid,opt);
  1009. }
  1010. else if(options.action == "up" || options.action == "down"){
  1011. ONEMAP.M.myLayerActions.changeFloor();
  1012. }
  1013. }
  1014. // 更改层级
  1015. function changeFloor(){
  1016. var li = $("#layerControlMenu .myLayers .mn-content li");
  1017. var layer = $("#mapHolder #map2DWrap .leaflet-layer");
  1018. var liLength = li.length;
  1019. var zidArr = new Array();
  1020. for(var i=0;i<liLength;i++){
  1021. zidArr.push(li.eq(i).attr("zid"));
  1022. for(var j=0;j<layer.length;j++){
  1023. if(layer.eq(j).attr("zid") == zidArr[i]){
  1024. layer.eq(j).css("z-index",layer.length-i);
  1025. }
  1026. }
  1027. }
  1028. }
  1029. // 设置透明度
  1030. function setOpacity(zid,opt){
  1031. map23DControl.tileLayer({
  1032. action: 'update',
  1033. guid: zid,
  1034. layer: {
  1035. opacity: opt
  1036. }
  1037. })
  1038. }
  1039. // 移除图层
  1040. function removeLayer(data){
  1041. if (data) {
  1042. modValue.thematicControlHtml.remove();
  1043. map23DControl.tileLayer({
  1044. action: 'remove',
  1045. guid: data
  1046. })
  1047. data = null;
  1048. // map2DViewer.map.removeControl(overLayerOpacityControl);
  1049. overLayerOpacityControl = null;
  1050. }
  1051. ONEMAP.D.overLayerCount--;
  1052. // 恢复缩放范围
  1053. if (ONEMAP.D.overLayerCount == 0) {
  1054. map2DViewer.map.setZoomScope(1, 19);
  1055. }
  1056. ONEMAP.M.myLayerActions.checkLayerNull();
  1057. // 移除选中状态
  1058. $('#thematicResultsList li.select').removeClass('select');
  1059. }
  1060. // 更改层级
  1061. function changeFloor(){
  1062. var li = $("#layerControlMenu .myLayers .mn-content li");
  1063. var layer = $("#mapHolder #map2DWrap .leaflet-layer");
  1064. var liLength = li.length;
  1065. var zidArr = new Array();
  1066. for(var i=0;i<liLength;i++){
  1067. zidArr.push(li.eq(i).attr("zid"));
  1068. for(var j=0;j<layer.length;j++){
  1069. if(layer.eq(j).attr("zid") == zidArr[i]){
  1070. layer.eq(j).css("z-index",layer.length-i);
  1071. }
  1072. }
  1073. }
  1074. }
  1075. /**
  1076. * 注册监听
  1077. * @type {Function}
  1078. */
  1079. function subscribe() {
  1080. // map2DViewer.map.on('layerOpacity:addFav', addFavThematic);
  1081. ONEMAP.C.publisher.subscribe(removeCurrentOverLayer, 'cleanMap');
  1082. };
  1083. /**
  1084. * 移除事件
  1085. * @type {Function}
  1086. */
  1087. function remove() {
  1088. }
  1089. return ONEMAP.M.thematic = {
  1090. init: init,
  1091. addOverLayerToMap:addOverLayerToMap,
  1092. removeCurrentOverLayer:removeCurrentOverLayer,
  1093. thematicData:modValue
  1094. };
  1095. });