| | |
| | | define(["base/AppEvent", |
| | | "base/ConfigData", |
| | | "dojo/_base/declare", |
| | | "dojo/_base/lang", |
| | | "dojo/dom", |
| | | "dojo/dom-construct", |
| | | "dojo/dom-attr", |
| | | "dojo/dom-class", |
| | | "dojo/on", |
| | | "utils/LayerUtil", |
| | | "utils/ConfigUtil", |
| | | "controls/toolbar/tools/Map3DTool", |
| | | "controls/toolbar/tools/SwipeTool", |
| | | "controls/toolbar/tools/ZoomInTool", |
| | | "controls/toolbar/tools/ZoomOutTool", |
| | | "controls/toolbar/tools/PanTool", |
| | | "controls/toolbar/tools/FullScreenTool", |
| | | "controls/toolbar/tools/ScreenWindowTool", |
| | | "controls/toolbar/tools/StreetViewTool", |
| | | "controls/toolbar/tools/MeasureLineTool", |
| | | "controls/toolbar/tools/MeasurePolygonTool", |
| | | "controls/toolbar/tools/ErrCorrectTool", |
| | | "controls/toolbar/tools/ClearTool", |
| | | "controls/toolbar/tools/CityLayerTool", |
| | | "controls/toolbar/tools/LocationTool", |
| | | "dojo/dom-style", |
| | | "dojo/domReady!" |
| | | ], |
| | | function (AppEvent, |
| | | "base/ConfigData", |
| | | "dojo/_base/declare", |
| | | "dojo/_base/lang", |
| | | "dojo/dom", |
| | | "dojo/dom-construct", |
| | | "dojo/dom-attr", |
| | | "dojo/dom-class", |
| | | "dojo/on", |
| | | "utils/LayerUtil", |
| | | "utils/ConfigUtil", |
| | | "controls/toolbar/tools/Map3DTool", |
| | | "controls/toolbar/tools/SwipeTool", |
| | | "controls/toolbar/tools/ZoomInTool", |
| | | "controls/toolbar/tools/ZoomOutTool", |
| | | "controls/toolbar/tools/PanTool", |
| | | "controls/toolbar/tools/FullScreenTool", |
| | | "controls/toolbar/tools/ScreenWindowTool", |
| | | "controls/toolbar/tools/StreetViewTool", |
| | | "controls/toolbar/tools/MeasureLineTool", |
| | | "controls/toolbar/tools/MeasurePolygonTool", |
| | | "controls/toolbar/tools/ErrCorrectTool", |
| | | "controls/toolbar/tools/ClearTool", |
| | | "controls/toolbar/tools/CityLayerTool", |
| | | "controls/toolbar/tools/LocationTool", |
| | | "dojo/dom-style", |
| | | "dojo/domReady!" |
| | | ], |
| | | function(AppEvent, |
| | | ConfigData, |
| | | declare, |
| | | lang, |
| | |
| | | //-------------------------------------------- |
| | | // 系统所有widget的配置 |
| | | //-------------------------------------------- |
| | | _widgetsConfig: [ |
| | | { |
| | | _widgetsConfig: [{ |
| | | "label": "分析研判", |
| | | "id": "AnalysisAndJudgment", |
| | | "widgetClass": "widgets/analysisAndJudgment/AnalysisAndJudgment", |
| | |
| | | "actived": false |
| | | }, |
| | | { |
| | | "label": "设备管理", |
| | | "id": "equipment", |
| | | "widgetClass": "widgets/equipment/ClientManagement", |
| | | "type": "sider", |
| | | "cssPath": "widgets/equipment/ClientManagement.css", |
| | | "actived": false |
| | | "label": "设备管理", |
| | | "id": "equipment", |
| | | "widgetClass": "widgets/equipment/ClientManagement", |
| | | "type": "sider", |
| | | "cssPath": "widgets/equipment/ClientManagement.css", |
| | | "actived": false |
| | | }, |
| | | { |
| | | "label": "警情调度", |
| | |
| | | "widgetClass": "widgets/aPoliceTeam/APoliceTeam", |
| | | "type": "sider", |
| | | "cssPath": "widgets/aPoliceTeam/APoliceTeam.css", |
| | | "actived": false |
| | | }, |
| | | { |
| | | "label": "处警队伍", |
| | | "id": "SecurityMap", |
| | | "widgetClass": "widgets/securityMap/SecurityMap", |
| | | "type": "sider", |
| | | "cssPath": "widgets/securityMap/SecurityMap.css", |
| | | "actived": false |
| | | }, |
| | | { |
| | |
| | | _widgetsTable: {}, |
| | | _activedButton: null, |
| | | _widgetId2TabButtonIndex: {}, |
| | | constructor: function () { |
| | | constructor: function() { |
| | | AppEvent.addAppEventListener(AppEvent.CONFIG_LOADED, lang.hitch(this, this.onConfigLoaded)); |
| | | AppEvent.addAppEventListener(AppEvent.BASE_MAP_LAYER_LOADED, lang.hitch(this, this.onMapLoaded)); |
| | | AppEvent.addAppEventListener(AppEvent.RUN_WIDGET, lang.hitch(this, this.onRunWidgetHandler)); |
| | | AppEvent.addAppEventListener(AppEvent.CLOSE_WIDGET, lang.hitch(this, this.onCloseWidgetHandler)); |
| | | }, |
| | | onConfigLoaded: function () { |
| | | onConfigLoaded: function() { |
| | | this._bodyDom = dom.byId("body"); |
| | | this._mapContentDom = dom.byId("mapcontentClass"); |
| | | this._topWidgetContainerDom = dom.byId("topWidgetContainer"); |
| | | }, |
| | | onMapLoaded: function (map) { |
| | | onMapLoaded: function(map) { |
| | | try { |
| | | this._map = map; |
| | | for (var i = 0; i < this._widgetsConfig.length; i++) { |
| | |
| | | /** |
| | | * 解析侧边栏的Widget |
| | | */ |
| | | _parseSiderWidget: function (widgetCfg) { |
| | | _parseSiderWidget: function(widgetCfg) { |
| | | if (widgetCfg.inited) { |
| | | this._loadWidget(widgetCfg.widgetClass, widgetCfg.id, widgetCfg.cssPath, function (widget) { |
| | | this._loadWidget(widgetCfg.widgetClass, widgetCfg.id, widgetCfg.cssPath, function(widget) { |
| | | domConstruct.place(widget.domNode, dom.byId("tabcontainer")); |
| | | widget.startup(); |
| | | widget.close(); |
| | |
| | | /** |
| | | * 解析顶部位置的Widget |
| | | */ |
| | | _parseTopWidget: function (widgetCfg) { |
| | | _parseTopWidget: function(widgetCfg) { |
| | | if (widgetCfg.actived) { |
| | | this._loadWidget(widgetCfg.widgetClass, widgetCfg.id, widgetCfg.cssPath, lang.hitch(this, function () { |
| | | this._loadWidget(widgetCfg.widgetClass, widgetCfg.id, widgetCfg.cssPath, lang.hitch(this, function() { |
| | | var widget = this._widgetsTable[widgetCfg.id]; |
| | | domConstruct.place(widget.domNode, this._topWidgetContainerDom); |
| | | widget.startup(); |
| | |
| | | /** |
| | | * 解析浮动在地图显示区域上的Widget |
| | | */ |
| | | _parseCoverWidget: function (widgetCfg) { |
| | | _parseCoverWidget: function(widgetCfg) { |
| | | if (widgetCfg.actived) { |
| | | this._loadWidget(widgetCfg.widgetClass, widgetCfg.id, widgetCfg.cssPath, lang.hitch(this, function () { |
| | | this._loadWidget(widgetCfg.widgetClass, widgetCfg.id, widgetCfg.cssPath, lang.hitch(this, function() { |
| | | var widget = this._widgetsTable[widgetCfg.id]; |
| | | domConstruct.place(widget.domNode, this._mapContentDom); |
| | | widget.startup(); |
| | |
| | | |
| | | }, |
| | | |
| | | onRunWidgetHandler: function (widgetId) { |
| | | onRunWidgetHandler: function(widgetId) { |
| | | var widgetCfg = this._getWidgetConfigById(widgetId); |
| | | if (!widgetCfg) { |
| | | alert("该模块不存在!"); |
| | |
| | | thisObj: this, |
| | | widgetCfg: widgetCfg |
| | | }; |
| | | this._loadWidget(widgetCfg.widgetClass, widgetId, widgetCfg.cssPath, lang.hitch(content, function () { |
| | | this._loadWidget(widgetCfg.widgetClass, widgetId, widgetCfg.cssPath, lang.hitch(content, function() { |
| | | var widget = this.thisObj._widgetsTable[this.widgetCfg.id]; |
| | | this.thisObj._runWidget(widget, this.widgetCfg); |
| | | })); |
| | |
| | | this._runWidget(widget, widgetCfg); |
| | | } |
| | | }, |
| | | onCloseWidgetHandler: function (widgetId) { |
| | | onCloseWidgetHandler: function(widgetId) { |
| | | var widgetCfg = this._getWidgetConfigById(widgetId); |
| | | if (!widgetCfg) { |
| | | return; |
| | |
| | | /** |
| | | * 运行Widget |
| | | */ |
| | | _runWidget: function (widget, widgetCfg) { |
| | | _runWidget: function(widget, widgetCfg) { |
| | | switch (widgetCfg.type) { |
| | | case "sider": |
| | | if (this._activedButton) { |
| | |
| | | /** |
| | | * 临时的实例化,因为还没有规划好怎么加载 |
| | | */ |
| | | _tempAppendOthers: function () { |
| | | _tempAppendOthers: function() { |
| | | var map = this._map; |
| | | var mapDomNode = dom.byId(map.id); |
| | | //创建常用工具条 |
| | | dojo.create("link", { |
| | | href: 'controls/toolbar/toolbar.css', |
| | | type: 'text/css', |
| | | rel: 'stylesheet' |
| | | }, |
| | | href: 'controls/toolbar/toolbar.css', |
| | | type: 'text/css', |
| | | rel: 'stylesheet' |
| | | }, |
| | | document.getElementsByTagName('head')[0]); |
| | | var toolbarDom = domConstruct.create("div", { |
| | | id: "toolBarDiv", |
| | | "class": "toolbar" |
| | | }, dom.byId('mainMapWidget')); |
| | | //全屏 |
| | | /*var tool = new FullScreenTool({ |
| | | "map": this._map |
| | | }); |
| | | domConstruct.place(tool.domNode, toolbarDom); |
| | | AppEvent.dispatchAppEvent(AppEvent.APPEND_TOOL, tool);*/ |
| | | /*var tool = new FullScreenTool({ |
| | | "map": this._map |
| | | }); |
| | | domConstruct.place(tool.domNode, toolbarDom); |
| | | AppEvent.dispatchAppEvent(AppEvent.APPEND_TOOL, tool);*/ |
| | | //放大 |
| | | var tool = new ZoomInTool({ |
| | | "map": this._map |
| | |
| | | hockId: ConfigData.mapWidgetId |
| | | }); |
| | | //漫游 |
| | | /*var tool = new Map3DTool({ |
| | | /*var tool = new Map3DTool({ |
| | | "map": this._map |
| | | }); |
| | | domConstruct.place(tool.domNode, toolbarDom); |
| | |
| | | }); |
| | | |
| | | }, |
| | | _onTabButtonClickHandler: function (evt) { |
| | | _onTabButtonClickHandler: function(evt) { |
| | | if (this._activedButton == evt.currentTarget) { |
| | | return; |
| | | } |
| | |
| | | if (widget == null) { |
| | | //Widget还未Load |
| | | var widgetCfg = this._getWidgetConfigById(widgetId); |
| | | this._loadWidget(widgetCfg.widgetClass, widgetId, widgetCfg.cssPath, lang.hitch(this, function () { |
| | | this._loadWidget(widgetCfg.widgetClass, widgetId, widgetCfg.cssPath, lang.hitch(this, function() { |
| | | widget = this._widgetsTable[widgetId]; |
| | | //this._confirmUserRightForSiderWidget(widget) |
| | | if (this._activedButton) { |
| | |
| | | } |
| | | //var loadwidget = lang.hitch(this, this._confirmUserRightForSiderWidget(widget)); |
| | | }, |
| | | _switchTab: function (widgetId) { |
| | | _switchTab: function(widgetId) { |
| | | var widget; |
| | | if (widgetId == this._defaultActivedSiderWidgetId) { |
| | | //第一次加载defaultWidget的时候,widget还未请求 |
| | |
| | | widget.domNode.parentNode.removeChild(widget.domNode); |
| | | } |
| | | widget = this._widgetsTable[widgetId]; |
| | | var loadfun = lang.hitch(this, function (widget, widgetId) { |
| | | var loadfun = lang.hitch(this, function(widget, widgetId) { |
| | | this._defaultActivedSiderWidgetId = widgetId; |
| | | domConstruct.place(widget.domNode, dom.byId("tabcontainer")); |
| | | if (widget.loaded() == false) { |
| | |
| | | }); |
| | | if (widget == null) { |
| | | var widgetCfg = this._getWidgetConfigById(widgetId); |
| | | this._loadWidget(widgetCfg.widgetClass, widgetId, widgetCfg.cssPath, lang.hitch(this, function () { |
| | | this._loadWidget(widgetCfg.widgetClass, widgetId, widgetCfg.cssPath, lang.hitch(this, function() { |
| | | widget = this._widgetsTable[widgetId]; |
| | | loadfun(widget, widgetId); |
| | | })); |
| | |
| | | } |
| | | |
| | | }, |
| | | _loadWidget: function (widgetUrl, widgetId, cssPath, callback) { |
| | | _loadWidget: function(widgetUrl, widgetId, cssPath, callback) { |
| | | if (cssPath && cssPath != "") { |
| | | dojo.create("link", { |
| | | href: cssPath, |
| | | type: "text/css", |
| | | rel: "stylesheet" |
| | | }, |
| | | href: cssPath, |
| | | type: "text/css", |
| | | rel: "stylesheet" |
| | | }, |
| | | document.getElementsByTagName("head")[0]); |
| | | } |
| | | require([widgetUrl], lang.hitch(this, function (WidgetClass) { |
| | | var widget = new WidgetClass({ |
| | | map: this._map, |
| | | id: widgetId |
| | | }); |
| | | this._widgetsTable[widgetId] = widget; |
| | | if (callback) |
| | | callback(widget); |
| | | }), |
| | | function (err) { |
| | | require([widgetUrl], lang.hitch(this, function(WidgetClass) { |
| | | var widget = new WidgetClass({ |
| | | map: this._map, |
| | | id: widgetId |
| | | }); |
| | | this._widgetsTable[widgetId] = widget; |
| | | if (callback) |
| | | callback(widget); |
| | | }), |
| | | function(err) { |
| | | console.log("load widget"); |
| | | console.log(err); |
| | | }); |
| | | }, |
| | | _getWidgetConfigById: function (widgetId) { |
| | | _getWidgetConfigById: function(widgetId) { |
| | | for (var i = 0; i < this._widgetsConfig.length; i++) { |
| | | if (this._widgetsConfig[i].id == widgetId) { |
| | | return this._widgetsConfig[i]; |
| | |
| | | } |
| | | } |
| | | }); |
| | | }); |
| | | }); |