123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- /**
- * [ONEMAP.M.gcmsThematic]
- * @return {[object]}
- */
- define(function(){
- //参数
- var modValue = {
- options:{}
- };
-
- /**
- * 模块初始化
- * @return {[type]} [description]
- */
- function init(options){
- remove();
- modValue.options = {};
- for(var op in options){
- modValue.options[op] = options[op];
- }
- //注册监听
- subscribe();
- //获取内容数据
- getDetailData({callback:function(){
- showThematic();
- }});
- }
- function getDetailData(options){
- ONEMAP.V.loading.load();
- $.ajax({
- url: onemapUrlConfig.gcmsServiceUrl+'/show/'+modValue.options['column_name']+'/'+modValue.options['article_id'],
- type:"GET",
- dataType: 'json'
- })
- .done(function(data) {
- ONEMAP.V.loading.loaded();
- if(data.code == 4){
- ONEMAP.C.noPermission('getDetailData');
- return false;
- }
- if(data.code == 3){
- ONEMAP.C.logout('getDetailData');
- }
- ONEMAP.D.gcmsCurArticleData = data['data'];
- options.callback();
- })
- .fail(function() {
- ONEMAP.V.loading.loaded();
- });
- }
- function showThematic(){
- if(ONEMAP.D.gcmsCurArticleData['record'][modValue.options['field_name']].length == 0){
- ONEMAP.C.publisher.publish({ type: 'warning', message: '没有专题图数据' }, 'noteBar::add');
- return false;
- }
- var thematicData = JSON.parse(ONEMAP.D.gcmsCurArticleData['record'][modValue.options['field_name']]);
- ONEMAP.V.loading.load();
- $.ajax({
- url: onemapUrlConfig.thematicDataUrl+'/production/metadata?production_id='+thematicData['guid'],
- type:"GET",
- dataType: 'json'
- })
- .done(function(data) {
- ONEMAP.V.loading.loaded();
- if(data.code == 4){
- ONEMAP.C.noPermission('getDetailData');
- }
- if(data.code == 3){
- ONEMAP.C.logout('getDetailData');
- }
- require(['modDir/atlas/atlasList'],function(atlasList){
- var layerObj = {
- guid:thematicData['guid'],
- name:'thematic_'+thematicData['guid'],
- center:[thematicData['center_lat'],thematicData['center_lon']],
- zoom:thematicData['min_zoom'],
- thumb_min_id:thematicData['thumb_min_id'],
- translate:thematicData['name'],
- min_zoom:thematicData['min_zoom'],
- max_zoom:thematicData['max_zoom'],
- data_type:thematicData['data_type'],
- map_type:thematicData['map_type'],
- showFavBtn:false,
- status:true
- }
- //atlasList._addSingleLayersControl();
- atlasList.addOverLayerToMap(layerObj);
- });
- })
- .fail(function() {
- ONEMAP.V.loading.loaded();
- });
-
- }
- function addThematicToMap(){
-
- }
- /**
- * 收藏专题图
- * @param {[type]} layerObj [description]
- */
- function _addFavThematic(layerObj){
- require(['modDir/userThematic'],function(userThematic){
- userThematic.addThematic(layerObj);
- });
- }
- /**
- * 注册监听
- * @type {Function}
- */
- function subscribe(){
- map2DViewer.map.on('layerOpacity:addFav',_addFavThematic);
- ONEMAP.C.publisher.subscribe(remove, 'cleanMap');
- ONEMAP.C.publisher.subscribe(remove,'gcmsArticleShowRemove');
- }
- /**
- * 取消监听
- * @type {Function}
- */
- function unSubscribe() {
- map2DViewer.map.off('layerOpacity:addFav',_addFavThematic);
- }
- /**
- * 模块移除
- * @return {[type]} [description]
- */
- function remove(){
- if(ONEMAP.M.thematic){
- ONEMAP.M.thematic.removeCurrentOverLayer();
- }
- unSubscribe();
- }
- return ONEMAP.M.gcmsThematic = {
- init:init,
- remove:remove
- }
- });
|