/** * 全景按钮 * @author Wenyb * @date 2015/6/29 */ define([ "dojo/_base/declare", "base/BaseControl", "dojo/text!controls/sceneControl/SceneControl.html", "iframe/jcyj/js/dataShow.js", "widgets/myModules/monitorSpots", "dojo/dom-style", "dojo/on", "base/AppEvent", "base/ConfigData", "dojo/_base/array", "dojo/dom-class", "dojo/dom-construct", "dojo/mouse", "dojo/dom-attr", "dojo/_base/lang", "esri/layers/GraphicsLayer", "esri/graphic", ], function( declare, BaseControl, template, dataShow, monitorSpots, domStyle, on, AppEvent, ConfigData, arrayUtil, domClass, domConstruct, mouse, domAttr, lang, GraphicsLayer, Graphic) { var Widget = declare("SceneControl", [BaseControl], { templateString: template, visibleGroupLayerId:null, visibleLayerSetId:null, sceneControl:null, noTextScene:null, constructor: function(options) { this.inherited(arguments); declare.safeMixin(this, options); this._map = options.map; //初始化全景图层 this.sceneControl = new GraphicsLayer({id: 'sceneControl'}); this.noTextScene = new GraphicsLayer({id: 'noTextScene'}) //给每个点添加点击事件 this.sceneControl.on('click', this.monitorSpotsOnClick); this.noTextScene.on('click', this.monitorSpotsOnClick); this._map.addLayer(this.sceneControl); this._map.addLayer(this.noTextScene); this._grouplayers = []; this._currentVisibleLayerlabel = null; // this.base_class = "mapswitch-container"; this._galleryDomTable = {}; this._maps2galleryTable = {}; this._galleryLeaveHandlerTable = {}; // var baseMaps = ConfigData.basemap.grouplayers; // for (var key in baseMaps) { // var gl = baseMaps[key]; // if (gl.visible == true) { // this._currentVisibleLayerlabel = gl.label; // } // this._grouplayers.push(gl.label); // } // this.gallery = ConfigData.basemap.gallerys[0]; // this.groups = ConfigData.basemap.grouplayers; // this.index = []; // this.galleryDom = null; // AppEvent.addAppEventListener(AppEvent.SWITCH_BASEMAP, lang.hitch(this, this.onSwitchBaseMapHandler)); }, startup: function() { ScenceControlObj = this; ScenceControlObj.treecheck = []; this.inherited(arguments); if (!!window.ActiveXObject || "ActiveXObject" in window){ var isIE = true; }else{ var isIE = false; } //获取数据并把点添加进图层 $.ajax({ url: getNativePath() + "panorama/queryAllPanoramas.do", success:function(res){ res = res.data; if(isIE){ var x = 9; }else{ var x = -2; } for(var i in res){ var myPoint1 = { "geometry": { "x": res[i].lon, "y": res[i].lat, "spatialReference": {"wkid": 4490} }, "attributes": { id: res[i].id, name: res[i].name, SceneUrl: res[i].url || null, x: res[i].lon, y: res[i].lat, }, "symbol": { "type": "esriPMS", "url": 'images/定位.png', "imageData": null, "contentType": "image/png", "width": 20, "height": 20, "angle": 0, "xoffset": 0, "yoffset": 12 } }; //添加带文字的图层 var text1 = { "geometry": { "x": res[i].lon, "y": res[i].lat, "spatialReference": {"wkid": 4490} }, "symbol": { "type": "esriTS", "color": [16, 139, 171, 255], "backgroundColor": [16, 139, 171, 255], "borderLineSize": 1, "borderLineColor": [16, 139, 171, 255], "verticalAlignment": 'bottom',// "horizontalAlignment": 'left',// "rightToLeft": true,// "angle": 0, "xoffset": 8, "yoffset": x, "kerning": true,// "font": { "family": "wryh", "size": 11, "style": "normal",// "weight": 'bold',// "decoration": 'none',// }, "text": res[i].name //only applicable when specified as a client-side graphic. } }; //每个点添加进图层 var gra1 = new Graphic(myPoint1); var textpt1 = new Graphic(text1); ScenceControlObj.sceneControl.add(gra1); ScenceControlObj.sceneControl.add(textpt1); } for(var z in res){ var myPoint2 = { "geometry": { "x": res[z].lon, "y": res[z].lat, "spatialReference": {"wkid": 4490} }, "attributes": { id: res[z].id, name: res[z].name, SceneUrl: res[z].url || null, x: res[z].lon, y: res[z].lat, }, "symbol": { "type": "esriPMS", "url": 'images/定位.png', "imageData": null, "contentType": "image/png", "width": 20, "height": 20, "angle": 0, "xoffset": 0, "yoffset": 12 } }; //每个点添加进图层 var gra2 = new Graphic(myPoint2); ScenceControlObj.noTextScene.add(gra2); } } }); //隐藏图层 var layer1 = this._map.getLayer("sceneControl"); layer1.setVisibility(false); var layer2 = this._map.getLayer("noTextScene"); layer2.setVisibility(false); sessionStorage.setItem('flag',false); var flag,num; var that = this; this._map.on("zoom-end", zomChange); function zomChange(event) { num = that._map.getZoom(); if(flag){ if(num>7){ layer1.setVisibility(true); layer2.setVisibility(false); }else{ layer2.setVisibility(true); layer1.setVisibility(false); } } } on(this.container, 'click', lang.hitch(this, function () { if(sessionStorage.getItem('flag')){ flag = sessionStorage.getItem('flag'); }else{ flag = false; } //如果zoom大于7,显示带文字的图层,不大于7显示只有点的图层 if(flag == 'false'){ flag = false; }else if(flag == 'true'){ flag = true; } flag = !flag; if(flag){ if(num>7){ if(layer1 && layer1.visible){ layer1.setVisibility(false); layer2.setVisibility(false); }else{ layer1.setVisibility(true); layer2.setVisibility(false); } }else{ if(layer2 && layer2.visible){ layer2.setVisibility(false); layer1.setVisibility(true); }else{ layer2.setVisibility(true); layer1.setVisibility(false); } } }else{ layer1.setVisibility(false); layer2.setVisibility(false); } sessionStorage.setItem('flag',flag); })); // var tableDom = domConstruct.create("table", {}, this.container); // domStyle.set(tableDom, "border-spacing", "0px 5px"); // arrayUtil.forEach(ConfigData.basemap.gallerys, lang.hitch(this, function(item, index) { // var trDom = domConstruct.create("tr", { // "galleryid": item.id // }, tableDom); // var tdDom = domConstruct.create("td", { // "galleryid": item.id // }, trDom); // // this._galleryDomTable[item.id] = tdDom; // this._maps2galleryTable[item.id] = []; // this._galleryLeaveHandlerTable[item.id] = null; // on(tdDom, mouse.enter, lang.hitch(this,this._onGalleryDomMouseEnter)); // on(tdDom, mouse.leave, lang.hitch(this, this._onGalleryDomMouseLeave)); // })); }, monitorSpotsOnClick: function (e) { var graphic = e.graphic; if(graphic.attributes){ var url = graphic.attributes.SceneUrl; if(url != undefined || url != null){ $('.sceneBox').show(); } $('.sceneBox').html(''+ ''); $(".video-close").unbind().click(function(){ $('.sceneBox').hide(); $('.sceneBox').html(""); }); } // $('.sceneBox').load(graphic.attributes.SceneUrl); // graphic.attributes.itemList = { // '实时数据': '鄱阳湖国家湿地公园', // '历史数据': '鄱阳湖国家湿地公园', // '全景': '鄱阳湖国家湿地公园', // '视频监控': '鄱阳湖国家湿地公园', // }; // //派发监测点弹窗 // AppEvent.dispatchAppEvent('popup', graphic); } }); return Widget; });