atlasCategory.js 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  1. /**
  2. * [ATLAS.M.atlasCategory]
  3. * @return {[object]}
  4. */
  5. define(['html!templates/atlas/atlasCategory',
  6. 'css!styles/atlas/atlasCategory'],
  7. function (tplLayout) {
  8. /**
  9. * 模块数据 用于数据存储和外部调用
  10. * @type {Object}
  11. */
  12. var modValue = {
  13. options: {
  14. type: 1,
  15. page: 1,
  16. pageSize: 20,
  17. searchWord: ''
  18. },
  19. //图集列表
  20. atlasCategoryData: null,
  21. simpleCampare: false
  22. }
  23. var ditukuStatu = false;
  24. /**
  25. * 初始化并订阅事件
  26. * @return {[type]} [description]
  27. */
  28. function init(type, data) {
  29. if (data == "search") {
  30. //console.log("search rightArea");
  31. //console.log(ONEMAP.D.user.searchKeyWord);
  32. modValue.options.searchWord = ONEMAP.D.user.searchKeyWord;
  33. }
  34. else {
  35. modValue.options.searchWord = "";
  36. }
  37. modValue.options.page = 1;
  38. // bindEvent();
  39. subscribe();
  40. if (type == 22) {
  41. modValue.options.type = 2;
  42. modValue.simpleCampare = true;
  43. showCompare(dataArr);
  44. }
  45. else if (type == 203) {
  46. // 搜索那边过来的
  47. // console.log("from search");
  48. ONEMAP.C.ditukuSearchResult = false;
  49. for (var i = 2; i < 5; i++) {
  50. modValue.options.type = i;
  51. getAtlasCategoryGai(i);
  52. }
  53. }
  54. else {
  55. modValue.options.type = parseInt(type);
  56. getAtlasCategory();
  57. }
  58. }
  59. /**
  60. * 界面事件绑定
  61. * @return {[type]} [description]
  62. */
  63. function bindEvent() {
  64. getAtlasCategory();
  65. }
  66. /**
  67. * 界面重置
  68. * @return {[type]} [description]
  69. */
  70. function layoutResize() {
  71. var marginWidth = (parseInt($('#atlasList').width() - 10) % 308 / parseInt($('#atlasList').width() / 308) / 2);
  72. $('#atlasList li').css({ marginLeft: marginWidth, marginRight: marginWidth });
  73. $("#thematicResultsList").css({ height: $("#sideBar").height() - $('#thematicCategoryList').height() - 180 });
  74. $('.atlas-list').css({ height: $('body').height() - 190 });
  75. $(".atlas-list").mCustomScrollbar('update');
  76. }
  77. /**
  78. * 面板的比对
  79. * @private
  80. */
  81. function simpleCampare(dataArr) {
  82. var openUrl, layerNum;
  83. var num = 0;
  84. var rightData = {};
  85. var getRightData = $("#layerControlMenu .myLayers .mn-content li:eq(" + dataArr[1] + ") .data-save").html();
  86. var leftData = JSON.parse($("#layerControlMenu .myLayers .mn-content li:eq(" + dataArr[0] + ") .data-save").html());
  87. var cid = $("#mapBaseLayerControl .choosemap .map-list li.active").attr("mid");
  88. if (typeof (getRightData) == "undefined") { // 单图层时与底图比较(需添加未选中时的条件)
  89. rightData = leftData;
  90. layerNum = "1&base=" + cid;
  91. }
  92. else {
  93. rightData = JSON.parse(getRightData);
  94. layerNum = 2;
  95. }
  96. // 此处放入地图对数据(guid)
  97. openUrl = 'atlasView.html?viewType=' + modValue.options.type +
  98. '&left=' + leftData.guid +
  99. '&right=' + rightData.guid +
  100. '&serialize=' + ONEMAP.C.encryption.enCode(JSON.stringify(modValue.options)) +
  101. '&layerNum=' + layerNum;
  102. var href = window.location.href;
  103. openUrl = href + openUrl;
  104. var utime = setInterval(function () {
  105. if (openUrl) {
  106. var windowOpen = window.open(openUrl);
  107. clearInterval(utime);
  108. } else if (num > 20) {
  109. windowOpen.close();
  110. clearInterval(utime);
  111. }
  112. num++
  113. }, 200);
  114. }
  115. /**
  116. * 获取图集列表
  117. * @type {Function}
  118. * @private
  119. */
  120. function getAtlasCategory() {
  121. ONEMAP.V.loading.load();
  122. var ajaxUrl = onemapUrlConfig.thematicDataUrl +
  123. '/shelf/products?types=[' + modValue.options.type + ']' +
  124. '&page=' + modValue.options.page +
  125. '&pagesize=' + modValue.options.pageSize +
  126. '&search=' + encodeURIComponent(modValue.options.searchWord);
  127. //console.log(ajaxUrl);
  128. $.ajax({
  129. type: "get",
  130. dataType: 'jsonp',
  131. url: ajaxUrl,
  132. success: function (data) {
  133. ONEMAP.V.loading.loaded();
  134. if (data.length > 0) {
  135. // console.log(data);
  136. if (data[0]['type'] === modValue.options.type) {
  137. modValue.atlasCategoryData = data[0];
  138. setAtlasCategoryList();
  139. }
  140. if (data[0]['products'].length <= 0) {
  141. // ONEMAP.C.publisher.publish({ type: 'warning', message: '暂无此搜索结果' }, 'noteBar::add');
  142. }
  143. } else {
  144. ONEMAP.C.publisher.publish({ type: 'error', message: '获取图集列表数据失败!' }, 'noteBar::add');
  145. }
  146. },
  147. error: function (data) {
  148. ONEMAP.V.loading.loaded();
  149. ONEMAP.C.publisher.publish({ type: 'error', message: '获取图集列表数据失败!' }, 'noteBar::add');
  150. }
  151. });
  152. }
  153. function getAtlasCategoryGai(typeF) {
  154. ONEMAP.V.loading.load();
  155. var ajaxUrl = onemapUrlConfig.thematicDataUrl +
  156. '/shelf/products?types=[' + modValue.options.type + ']' +
  157. '&page=' + modValue.options.page +
  158. '&pagesize=' + modValue.options.pageSize +
  159. '&search=' + encodeURIComponent(modValue.options.searchWord);
  160. //console.log(ajaxUrl);
  161. $.ajax({
  162. type: "get",
  163. dataType: 'jsonp',
  164. url: ajaxUrl,
  165. success: function (data) {
  166. ONEMAP.V.loading.loaded();
  167. if (data.length > 0) {
  168. // console.log(data);
  169. if (data[0]['type'] === modValue.options.type) {
  170. modValue.atlasCategoryData = data[0];
  171. setAtlasCategoryList();
  172. }
  173. if (data[0]['total'] == 0) {
  174. // console.log("无结果");
  175. $("#placePanel .thematic-content .thematic-title li").eq(typeF - 1).hide();
  176. }
  177. else {
  178. // console.log("youjieguo");
  179. ONEMAP.C.ditukuSearchResult = true;
  180. $("#placePanel .thematic-content .thematic-title li").eq(typeF - 1).show();
  181. // setTimeout(function(){
  182. if (ditukuStatu == false && parseInt($("#placePanel .thematic-content .thematic-title li").eq(0).css("height")) == 0) { //异步error
  183. // if(ditukuStatu == false){
  184. // console.log("xi")
  185. ditukuStatu = true;
  186. $("#placePanel .thematic-content .thematic-title li").eq(typeF - 1).addClass("active");
  187. $("#placePanel .thematic-content .thematic-title li").eq(typeF - 1).click();
  188. }
  189. // },300)
  190. }
  191. if (typeF == 4) {
  192. var ph = parseInt($("#placePanel .thematic-content .thematic-search-list").css("height"));
  193. // console.log(ph);
  194. // console.log(ONEMAP.C.ditukuSearchResult);
  195. var li = $("#placePanel .thematic-content .thematic-title li");
  196. // for(if())
  197. if (ph == 0 && ONEMAP.C.ditukuSearchResult == false) {
  198. // if(ph == 0 && ONEMAP.C.ditukuSearchResult == false && !li.eq(0).hasClass("active")){
  199. // console.log("asdf0")
  200. $("#placePanel .thematic-content").hide();
  201. }
  202. else {
  203. $("#placePanel .thematic-content").show();
  204. }
  205. if ($(".meteo-search-result-list").text() == "") {
  206. $(".meteo-search").hide();
  207. }
  208. else {
  209. $(".meteo-search").show();
  210. }
  211. }
  212. } else {
  213. ONEMAP.C.publisher.publish({ type: 'error', message: '获取图集列表数据失败!' }, 'noteBar::add');
  214. }
  215. },
  216. error: function (data) {
  217. ONEMAP.V.loading.loaded();
  218. ONEMAP.C.publisher.publish({ type: 'error', message: '获取图集列表数据失败!' }, 'noteBar::add');
  219. }
  220. });
  221. }
  222. /**
  223. * 获取地图对信息并直接跳转地图对比
  224. * @private
  225. */
  226. function showCompare(aid) {
  227. ONEMAP.V.loading.load();
  228. var ajaxUrl = onemapUrlConfig.thematicDataUrl + '/production/product_category?' +
  229. 'production_id=' + aid;
  230. var windowOpen = window.open();
  231. var atlasUrl = onemapUrlConfig.atlasLibraryUrl;
  232. var openUrl;
  233. var num = 0;
  234. $.ajax({
  235. type: "get",
  236. dataType: 'jsonp',
  237. url: ajaxUrl,
  238. success: function (data) {
  239. // console.log(data);
  240. ONEMAP.V.loading.loaded();
  241. if (data.category.length > 1) {
  242. openUrl = atlasUrl + '/atlasView.html?viewType=' + modValue.options.type +
  243. '&left=' + data.category[0].list[0]['guid'] +
  244. '&right=' + data.category[1].list[0]['guid'] +
  245. '&serialize=' + ONEMAP.C.encryption.enCode(JSON.stringify(modValue.options));
  246. } else {
  247. openUrl = atlasUrl + '/atlasView.html?viewType=' + modValue.options.type +
  248. '&left=' + data.category[0].list[0]['guid'] +
  249. '&right=' + data.category[0].list[1]['guid'] +
  250. '&serialize=' + ONEMAP.C.encryption.enCode(JSON.stringify(modValue.options));
  251. }
  252. },
  253. error: function (data) {
  254. ONEMAP.V.loading.loaded();
  255. ONEMAP.C.publisher.publish({ type: 'error', message: '获取地图对数据失败!' }, 'noteBar::add');
  256. }
  257. });
  258. var utime = setInterval(function () {
  259. if (openUrl) {
  260. windowOpen.location = openUrl;
  261. clearInterval(utime);
  262. } else if (num > 20) {
  263. windowOpen.close();
  264. clearInterval(utime);
  265. }
  266. num++
  267. }, 200);
  268. }
  269. /**
  270. * 设置地图集列表
  271. * @type {Function}
  272. * @private
  273. */
  274. function setAtlasCategoryList() {
  275. if (modValue.atlasCategoryData.products.length > 0) {
  276. var ul = $('<ul class="thematic-list"></ul>');
  277. $("#thematicCategoryList").hide();
  278. $.each(modValue.atlasCategoryData.products, function (index, val) {
  279. var atlas = val;
  280. var li = $('<li aid="' + atlas.guid + '">' +
  281. '<img src="' + map23DConfig.map23DAssetsUrl + '/images/atlas/bookImg.png"/>' +
  282. '<span class="cover"></span><span class="name">' + atlas.name + '</span></li>');
  283. li.bind('click', { da: atlas, page: modValue.atlasCategoryData.page }, function (e) {
  284. $('#atlasList .li-select').removeClass('li-select');
  285. $(this).addClass('li-select');
  286. //如果是地图对,直接进入对比阅读
  287. if (modValue.options.type === 2) {
  288. if (modValue.simpleCampare == true) {
  289. simpleCampare($(this).attr('aid'))
  290. }
  291. else {
  292. showCompare($(this).attr('aid'));
  293. }
  294. } else if (modValue.options.type === 1) {//进入单幅图
  295. $("#thematicCategoryList").show();
  296. showSingleAtlas($(this).attr('aid'), e.data.page);
  297. } else {//进入图集
  298. showAtlas($(this).attr('aid'));
  299. }
  300. });
  301. li.appendTo(ul);
  302. });
  303. $("#thematicResultsList .item-list").empty().append(ul);
  304. $("#thematicResultsList").attr("layerType", modValue.options.type);
  305. // // 从搜索条中读入
  306. // if(ONEMAP.D.user.searchInsert){
  307. // $("#thematicResultsList .item-list").empty().append(ONEMAP.D.user.searchKeyWordAtlasResult);
  308. // ONEMAP.D.user.searchKeyWordAtlasResult = null;
  309. // }
  310. layoutResize();
  311. //分页
  312. //
  313. if ((modValue.options.page * modValue.options.pagesize) >= modValue.atlasCategoryData.total) {
  314. // console.log("page test");
  315. $("#thematicPage").hide();
  316. return;
  317. }
  318. $("#thematicPage").empty();
  319. var countPages = (parseInt(modValue.atlasCategoryData.total % modValue.atlasCategoryData.pagesize) > 0 ? parseInt(modValue.atlasCategoryData.total / modValue.atlasCategoryData.pagesize + 1) : parseInt(modValue.atlasCategoryData.total / modValue.atlasCategoryData.pagesize));
  320. if (countPages == 0) {
  321. countPages = 1;
  322. }
  323. var _pageJump = $('<div class="firstpage"></div>' +
  324. '<div class="uppage"></div>' +
  325. '<div class="fg"></div>' +
  326. '<div id="thematicPageJump" class="count">' +
  327. ' <span>' + modValue.atlasCategoryData.page + '/' + countPages + '页</span>' +
  328. '</div>' +
  329. '<div class="fg"></div>' +
  330. '<div class="nextpage"></div>' +
  331. '<div class="endpage"></div>'
  332. );
  333. _pageJump.appendTo($("#thematicPage"));
  334. if (modValue.atlasCategoryData.page == 1) {
  335. $("#thematicPage .firstpage").css("background", "url(../images/layout/page_11.png) no-repeat 7px 11px")
  336. $("#thematicPage .uppage").css("background", "url(../images/layout/page_13.png) no-repeat 10px 11px")
  337. $("#thematicPage .nextpage").css("background", "url(../images/layout/page_06ch.png) no-repeat 10px 11px")
  338. $("#thematicPage .endpage").css("background", "url(../images/layout/page_08ch.png) no-repeat 7px 11px")
  339. } else if (modValue.atlasCategoryData.page == countPages) {
  340. $("#thematicPage .firstpage").css("background", "url(../images/layout/page_11ch.png) no-repeat 7px 11px")
  341. $("#thematicPage .uppage").css("background", "url(../images/layout/page_13ch.png) no-repeat 10px 11px")
  342. $("#thematicPage .nextpage").css("background", "url(../images/layout/page_06.png) no-repeat 10px 11px")
  343. $("#thematicPage .endpage").css("background", "url(../images/layout/page_08.png) no-repeat 7px 11px")
  344. } else {
  345. $("#thematicPage .firstpage").css("background", "url(../images/layout/page_11ch.png) no-repeat 7px 11px")
  346. $("#thematicPage .uppage").css("background", "url(../images/layout/page_13ch.png) no-repeat 10px 11px")
  347. $("#thematicPage .nextpage").css("background", "url(../images/layout/page_06ch.png) no-repeat 10px 11px")
  348. $("#thematicPage .endpage").css("background", "url(../images/layout/page_08ch.png) no-repeat 7px 11px")
  349. }
  350. $(".firstpage").bind("click", function () {
  351. modValue.atlasCategoryData.page = 1;
  352. var op = "f";
  353. clickpage(modValue.atlasCategoryData.page, countPages);
  354. $("#thematicPageJump span").html(modValue.atlasCategoryData.page + "/" + countPages + "页");
  355. })
  356. $(".uppage").bind("click", function () {
  357. modValue.atlasCategoryData.page--
  358. var op = "u";
  359. if (modValue.atlasCategoryData.page < 1) {
  360. modValue.atlasCategoryData.page = 1
  361. } else {
  362. clickpage(modValue.atlasCategoryData.page, countPages);
  363. $("#thematicPageJump span").html(modValue.atlasCategoryData.page + "/" + countPages + "页");
  364. }
  365. })
  366. $(".nextpage").bind("click", function () {
  367. modValue.atlasCategoryData.page++
  368. var op = "n";
  369. if (modValue.atlasCategoryData.page > countPages) {
  370. modValue.atlasCategoryData.page = countPages
  371. } else {
  372. clickpage(modValue.atlasCategoryData.page, countPages);
  373. $("#thematicPageJump span").html(modValue.atlasCategoryData.page + "/" + countPages + "页");
  374. }
  375. })
  376. $(".endpage").bind("click", function () {
  377. modValue.atlasCategoryData.page = countPages;
  378. var op = "e";
  379. clickpage(modValue.atlasCategoryData.page, countPages);
  380. $("#thematicPageJump span").html(modValue.atlasCategoryData.page + "/" + countPages + "页");
  381. })
  382. $("#thematicSearchKey").bind('input porpertychange', function (e) {
  383. var searchVal = $("#thematicSearchKey").val();
  384. if (searchVal == "") {
  385. modValue.options.searchWord = "";
  386. getAtlasCategory();
  387. }
  388. })
  389. $("#thematicPageJump .page_num").bind('keydown', function (e) {
  390. if (e.keyCode === 13) {
  391. var pageJump = parseInt($("#thematicPageJump .page_num").val());
  392. if (!pageJump || pageJump > countPages) {
  393. return;
  394. } else {
  395. showThematic({ page: parseInt(pageJump), });
  396. }
  397. }
  398. });
  399. var _themtiicPageBtnGroup = $('<div class="btn-group"></div>').appendTo($("#thematicPage"));
  400. if (modValue.atlasCategoryData.pagesize < modValue.atlasCategoryData.total) {
  401. if (modValue.atlasCategoryData.page == 1) {
  402. var abtnNext = $('<button type="button" class="btn btn2 btn-small next" pid=' + (modValue.atlasCategoryData.page + 1) + '>下一页</button>');
  403. } else if (countPages == modValue.atlasCategoryData.page && modValue.atlasCategoryData.total > modValue.atlasCategoryData.pagesize) {
  404. var abtnPrev = $('<button type="button" class="btn btn2 btn-small prev" pid=' + (modValue.atlasCategoryData.page - 1) + '>上一页</button>');
  405. } else {
  406. var abtnPrev = $('<button type="button" class="btn btn2 btn-small prev" pid=' + (modValue.atlasCategoryData.page - 1) + '>上一页</button>');
  407. var abtnNext = $('<button type="button" class="btn btn2 btn-small next" pid=' + (modValue.atlasCategoryData.page + 1) + '>下一页</button>');
  408. }
  409. $("#thematicPage .btn").on("click", function () {
  410. showThematic({ page: parseInt($(this).attr('pid')) });
  411. });
  412. }
  413. $("#thematicPage").show();
  414. }
  415. else {
  416. $("#thematicResultsList .item-list").empty()
  417. var tp;
  418. if (modValue.atlasCategoryData.type == 2) {
  419. tp = "地图对"
  420. } else if (modValue.atlasCategoryData.type == 3) {
  421. tp = "系列图"
  422. } else if (modValue.atlasCategoryData.type == 4) {
  423. tp = "地图集"
  424. }
  425. // $('<div id="noListData">地图库暂无此数据!</div>').appendTo($('#atlasList'));
  426. $('<div id="noListData">' + tp + '暂无此数据!</div>').appendTo($("#thematicResultsList .item-list").empty());
  427. //ONEMAP.C.publisher.publish({ type: 'warning', message: '地图库暂无此数据!' }, 'noteBar::add');
  428. }
  429. }
  430. /**
  431. * 换页点击事件
  432. */
  433. function clickpage(op, allp) {
  434. if (op == 1) {
  435. $("#thematicPage .firstpage").css("background", "url(../images/layout/page_11.png) no-repeat 7px 11px")
  436. $("#thematicPage .uppage").css("background", "url(../images/layout/page_13.png) no-repeat 10px 11px")
  437. $("#thematicPage .nextpage").css("background", "url(../images/layout/page_06ch.png) no-repeat 10px 11px")
  438. $("#thematicPage .endpage").css("background", "url(../images/layout/page_08ch.png) no-repeat 7px 11px")
  439. } else if (op == allp) {
  440. $("#thematicPage .firstpage").css("background", "url(../images/layout/page_11ch.png) no-repeat 7px 11px")
  441. $("#thematicPage .uppage").css("background", "url(../images/layout/page_13ch.png) no-repeat 10px 11px")
  442. $("#thematicPage .nextpage").css("background", "url(../images/layout/page_06.png) no-repeat 10px 11px")
  443. $("#thematicPage .endpage").css("background", "url(../images/layout/page_08.png) no-repeat 7px 11px")
  444. } else {
  445. $("#thematicPage .firstpage").css("background", "url(../images/layout/page_11ch.png) no-repeat 7px 11px")
  446. $("#thematicPage .uppage").css("background", "url(../images/layout/page_13ch.png) no-repeat 10px 11px")
  447. $("#thematicPage .nextpage").css("background", "url(../images/layout/page_06ch.png) no-repeat 10px 11px")
  448. $("#thematicPage .endpage").css("background", "url(../images/layout/page_08ch.png) no-repeat 7px 11px")
  449. }
  450. modValue.options.page = parseInt(op);
  451. showThematic({ page: parseInt(op), searchType: 'byPage' });
  452. };
  453. /**
  454. * 显示指定参数的专题列表
  455. * @type {Function}
  456. * @param options {Object} {}
  457. */
  458. function showThematic(options) {
  459. ONEMAP.T.objExtend(modValue.options, options, true);
  460. getPageResult(modValue.options);
  461. };
  462. /**
  463. * 根据options查询专题图
  464. * @type {Function}
  465. * @param options {Object} {page:页数,`:每页条数,searchType:查询类型 "byPage"/"byId"/"byKeyWord}
  466. * @private
  467. */
  468. function getPageResult(options) {
  469. switch (options.searchType) {
  470. case "byPage":
  471. ONEMAP.V.loading.load();
  472. byDefault(function (data) {
  473. ONEMAP.V.loading.loaded();
  474. // if (!data.hasOwnProperty('map_list')) {
  475. // setNotResultHtml('没有搜索到相关的信息。');
  476. // $("#thematicPage").hide();
  477. // } else {
  478. // modValue.thematicDataResult = data;
  479. // console.log(data);
  480. modValue.atlasCategoryData = data[0];
  481. setAtlasCategoryList();
  482. // setAtlasCategoryList();
  483. // }
  484. });
  485. break;
  486. case "byKeyWord":
  487. ONEMAP.V.loading.load();
  488. byKeyWord(options.searchKeyWord, function (data) {
  489. ONEMAP.V.loading.loaded();
  490. // if (!data.hasOwnProperty('map_list')) {
  491. // setNotResultHtml('没有搜索到 ' + options.searchKeyWord + ' 的信息。');
  492. // $("#thematicPage").hide();
  493. // } else {
  494. // modValue.thematicDataResult = data;
  495. // setAtlasCategoryList();
  496. // }
  497. modValue.atlasCategoryData = data[0];
  498. setAtlasCategoryList();
  499. });
  500. break;
  501. }
  502. };
  503. /**
  504. * 根据 options 参数获取 图集信息
  505. * @param callback_func {Function} 回调方法
  506. * @return {Object}
  507. */
  508. function byDefault(callback_func) {
  509. var ajaxUrl = onemapUrlConfig.thematicDataUrl +
  510. '/shelf/products?types=[' + modValue.options.type + ']' +
  511. '&page=' + modValue.options.page +
  512. '&pagesize=' + modValue.options.pageSize +
  513. '&search=' + encodeURIComponent(modValue.options.searchWord);
  514. // var ajaxUrl = onemapUrlConfig.thematicDataUrl + '/map/list' + '?types=[1,2,4]&page=' + modValue.options.page + '&pagesize=' + modValue.options.pageSize + '&region=' + modValue.options.region + '&area=' + modValue.options.area;
  515. // if (modValue.options.theme != null && modValue.options.theme != 'undefined') {
  516. // ajaxUrl += '&theme=' + modValue.options.theme;
  517. // }
  518. ONEMAP.V.loading.load();
  519. $.ajax({
  520. url: ajaxUrl,
  521. type: 'GET',
  522. dataType: 'jsonp'
  523. })
  524. .done(function (data) {
  525. ONEMAP.V.loading.loaded();
  526. callback_func(data);
  527. })
  528. .fail(function () {
  529. ONEMAP.V.loading.loaded();
  530. });
  531. };
  532. function showAtlas(aid) {
  533. var atlasUrl = onemapUrlConfig.atlasLibraryUrl;
  534. var windowOpen = window.open();
  535. var openUrl = atlasUrl + '/atlasView.html?viewType=' + modValue.options.type + '&' +
  536. 'productionId=' + aid + '&serialize=' + ONEMAP.C.encryption.enCode(JSON.stringify(modValue.options));
  537. windowOpen.location = openUrl;
  538. }
  539. /**
  540. * 注册订阅
  541. * @type {Function}
  542. * 推送:ATLAS.C.publisher.publish(options,'atlasCategory::type');
  543. * 订阅:ATLAS.C.publisher.subscribe(layoutResize,'sideBarLayoutChange');
  544. */
  545. function subscribe() {
  546. ONEMAP.C.publisher.subscribe(function () {
  547. map.invalidateSize();
  548. }, 'atlasView::layoutResize');
  549. }
  550. /**
  551. * 取消订阅
  552. * @type {Function}
  553. * 取消订阅:ATLAS.C.publisher.unSubscribe(layoutResize,'sideBarLayoutChange');
  554. */
  555. function unSubscribe() { }
  556. /**
  557. * 模块移除
  558. * @return {[type]} [description]
  559. */
  560. function remove() {
  561. //取消订阅
  562. //unSubscribe();
  563. }
  564. return ONEMAP.M.atlasCategory = {
  565. init: init,
  566. layoutResize: layoutResize
  567. }
  568. });