123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257 |
- /**
- * [ONEMAP.M.projectController]
- * @return {[object]}
- */
- define(function(tplLayout) {
- /**
- * 初始化并订阅事件
- * @return {[type]} [description]
- */
- /**
- * 测试数据
- */
- var mn_data = {
- "guid": "",
- "initial_zoom": 5,
- "center_lat": 31.0331660206555,
- "center_lon": 107.20230990329375,
- "max-zoom": 15,
- "min-zoom": 1,
- "zoom": 5,
- "name": ""
- }
- /**
- * 模块数据 用于数据存储和外部调用
- * @type {Object}
- * 数据存放
- */
- var modValue = {
- options : {
- page: 1, //页数
- pageSize: 24, //每页条数
- searchType: 'byPage', //搜索类型
- searchKeyWord: '', //搜索关键字
- searchId: 0, //搜索ID
- theme: null, //分类
- region: '', //当前区域 0 全球
- area: ''
- },
- guidGroup:{
- },
- //查询数据集合
- thematicDataResult:null,
- //专题图分类
- thematicCategory:[],
- DOMid:null,
- ids:[]
- }
- function init(dm) {
- if (!status.initialized) {
- subscribe();
- bindEvent();
- status.initialized = true;
- }
- mn_data.guid = dm.next().attr("guid");
- mn_data.name = dm.next().html();
- if(dm.is(':checked')){
- addLayer(mn_data); // 添加图层
- var options = {
- action: "add",
- DOM:{
- guid: modValue.currentOverLayerGuid,
- type: "layer",
- name: mn_data.name,
-
- },
- mod: "test",
- testLayerID: mn_data.guid
- }
- dm.addClass(options.DOM.guid);
-
- modValue.DOMid = ONEMAP.M.myLayers.myLayerControl(options); // 添加信息到“我的图层”
- // modValue.ids.push([modValue.DOMid,options.DOM.guid]);
- // //console.log(modValue.DOMid);
- ONEMAP.C.publisher.subscribe(layerAction, options.DOM.guid);
- }
- else{
-
- // 从上部移除我的图层中的对应节点
- var getClass = dm.attr("class");
- var rmvClass = "." + getClass;
- $(rmvClass).removeAttr("checked"); // 移除选中状态
- var testData = $(rmvClass).eq(1).next().next().attr("guid");
- // //console.log(testData);
- var options = {
- action: "remove",
- DOMid: modValue.currentOverLayerGuid
- }
- removeLayer(testData);
- ONEMAP.M.myLayers.myLayerControl(options); // 移除数据层
- dm.removeClass(getClass); // 移除上部对应class
- ONEMAP.M.layerControlMenu.checkLayerNull();
- }
- }
- function bindEvent(){
-
- }
- /**
- * 设置界面
- */
- function setLayout() {
- }
- function layoutResize() {
-
- }
- // 监听图层操作动作
- function layerAction(options){
- //console.log(options);
- //console.log(modValue.ids);
- if(options.action == "remove"){
- //console.log("remove");
- removeLayer(options.guid);
- }
- else if(options.action == "opacity"){
- var opt = options.options.opacity;
- setOpacity(options.guid,opt);
- }
- else if(options.action == "up" || options.action == "down"){
- ONEMAP.M.myLayerActions.changeFloor();
- }
- }
- // 更改层级
- function changeFloor(){
- var li = $("#layerControlMenu .myLayers .mn-content li");
- var layer = $("#mapHolder #map2DWrap .leaflet-layer");
- var liLength = li.length;
- var zidArr = new Array();
- for(var i=0;i<liLength;i++){
- zidArr.push(li.eq(i).attr("zid"));
- for(var j=0;j<layer.length;j++){
- if(layer.eq(j).attr("zid") == zidArr[i]){
- layer.eq(j).css("z-index",layer.length-i);
- }
- }
- }
- }
- // 设置透明度
- function setOpacity(zid,opt){
- map23DControl.tileLayer({
- action: 'update',
- guid: zid,
- layer: {
- opacity: opt
- }
- })
- }
- // 检查我的图层是否为空
- function checkLayerNull(){
- // 我的图层暂无数据时
- if(typeof($("#layerControlMenu .myLayers .mn-content li").eq(0).html()) == "undefined"){
- $("#layerControlMenu .mn-content p.tip-none").show();
- }
- else{
- $("#layerControlMenu .mn-content p.tip-none").hide();
- }
- }
- // 添加图层
- function addLayer(data){
- $("#layerControlMenu .mn-content p.tip-none").hide();
- //添加到23D地图上
- modValue.currentOverLayerGuid = map23DControl.tileLayer({
- action: 'add',
- layer: {
- url2D: onemapUrlConfig.thematicTileUrl + '/' + data.guid + '?l={z}&x={x}&y={y}',
- url3D: onemapUrlConfig.thematicTileUrl + '/' + data.guid + '?l={z}&x={x}&y={y}',
- //url3D: onemapUrlConfig.thematicTileFo3DUrl + '/' + data.guid + '?z=%d&x=%d&y=%d',
- minZoom: data['min_zoom'],
- maxZoom: data['max_zoom'],
- maxNativeZoom: data['max_zoom'],
- attribution: '',
- opacity: 1,
- imageType: 'png',
- name:data.name,
- guid:data.guid
- }
- })
- map23DControl.setView({
- center: {
- lat: data['center_lat'],
- lng: data['center_lon']
- },
- zoom: data['zoom']
- })
- map2DViewer.map.setZoomScope(data['min_zoom'],data['max_zoom']);
- }
-
- // 移除图层
- function removeLayer(data){
- if (data) {
- modValue.thematicControlHtml.remove();
- map23DControl.tileLayer({
- action: 'remove',
- guid: data
- })
- data = null;
- // map2DViewer.map.removeControl(overLayerOpacityControl);
- overLayerOpacityControl = null;
- }
- ONEMAP.D.overLayerCount--;
- if (ONEMAP.D.overLayerCount == 0) {
- map2DViewer.map.setZoomScope(1, 19);
- }
- }
- // 更改层级
- function changeFloor(){
- var li = $("#layerControlMenu .myLayers .mn-content li");
- var layer = $("#mapHolder #map2DWrap .leaflet-layer");
- var liLength = li.length;
- var zidArr = new Array();
- for(var i=0;i<liLength;i++){
- zidArr.push(li.eq(i).attr("zid"));
- for(var j=0;j<layer.length;j++){
- if(layer.eq(j).attr("zid") == zidArr[i]){
- layer.eq(j).css("z-index",layer.length-i);
- }
- }
- }
- }
- /**
- * 注册订阅
- * @type {Function}
- * 推送:ONEMAP.C.publisher.publish(options,'moduleName::type');
- * 订阅:ONEMAP.C.publisher.subscribe(layoutResize,'sideBarLayoutChange');
- */
- function subscribe() {
- ONEMAP.C.publisher.subscribe(layoutResize, 'menuListClick');
- // ONEMAP.C.publisher.subscribe(remove, 'cleanMap');
- }
- /**
- * 取消订阅
- * @type {Function}
- * 取消订阅:ONEMAP.C.publisher.unSubscribe(layoutResize,'sideBarLayoutChange');
- */
- function unSubscribe() {
- }
- return ONEMAP.M.testInfo = {
- init: init
- }
- });
|