| New file |
| | |
| | | /** |
| | | * 地图浏览工具的基类 |
| | | * @author 温杨彪 2015-9-13 |
| | | **/ |
| | | define([ |
| | | "dojo/_base/declare", |
| | | "controls/toolbar/tools/BaseTool", |
| | | "esri/toolbars/draw", |
| | | "dojo/on", |
| | | "base/utils/RendererUtil", |
| | | "dojo/_base/lang" |
| | | ], function( |
| | | declare, |
| | | BaseTool, |
| | | Draw, |
| | | on, |
| | | RendererUtil, |
| | | lang |
| | | ) { |
| | | var RL = declare([BaseTool], { |
| | | _drawTool:null, |
| | | _drawType:"", |
| | | _isDrawOnece:true, |
| | | constructor: function(args) { |
| | | this._normalIconClass="tool-zoomIn-normal"; |
| | | this._overIconClass="tool-zoomIn-over"; |
| | | this._selectedIconClass="tool-zoomIn-select"; |
| | | }, |
| | | _setIsDrawOneceAttr:function(value) |
| | | { |
| | | this._isDrawOnece = value; |
| | | }, |
| | | _getIsDrawOneceAttr:function() |
| | | { |
| | | return this._isDrawOnece; |
| | | }, |
| | | _setDrawTypeAttr:function(value) |
| | | { |
| | | this._drawType = value; |
| | | }, |
| | | _getDrawTypeAttr:function() |
| | | { |
| | | return this._drawType; |
| | | }, |
| | | activate:function(args) |
| | | { |
| | | if(!this._drawTool.map) |
| | | { |
| | | this._drawTool.map=this.map; |
| | | } |
| | | this.inherited(arguments); |
| | | this._drawTool.activate(this._drawType); |
| | | this.map.infoWindow.hide(); |
| | | this.map.setInfoWindowOnClick(false); |
| | | }, |
| | | postCreate:function() |
| | | { |
| | | this.inherited(arguments); |
| | | this._drawTool = new Draw(this.map); |
| | | var smsSymbol = RendererUtil.createSymbol({ |
| | | "type":"SimpleMarkerSymbol", |
| | | "style":"circle", |
| | | "size":12, |
| | | "color":"#00ffff" |
| | | }); |
| | | this._drawTool.setMarkerSymbol(smsSymbol); |
| | | |
| | | var slsSymbol=RendererUtil.createSymbol({ |
| | | "type":"SimpleLineSymbol", |
| | | "style":"dot", |
| | | "width":3, |
| | | "color":"#292424" |
| | | }) |
| | | |
| | | this._drawTool.setLineSymbol(slsSymbol); |
| | | |
| | | var sfsSymbol=RendererUtil.createSymbol({ |
| | | "type":"SimpleFillSymbol", |
| | | "style":"solid", |
| | | "color":"#292424", |
| | | "alpha":0.5, |
| | | "outline":{ |
| | | "type":"SimpleLineSymbol", |
| | | "style":"dot", |
| | | "width":3, |
| | | "color":"#292424" |
| | | } |
| | | }); |
| | | |
| | | this._drawTool.setFillSymbol(sfsSymbol); |
| | | |
| | | on(this._drawTool,"draw-end",lang.hitch(this,this.onDrawEndHandler)); |
| | | }, |
| | | deactivate:function() |
| | | { |
| | | if(!this._enable || !this._activated) |
| | | return; |
| | | this.inherited(arguments); |
| | | try |
| | | { |
| | | this._drawTool.deactivate(); |
| | | } |
| | | catch(err) |
| | | { |
| | | |
| | | } |
| | | this.map.setInfoWindowOnClick(true); |
| | | }, |
| | | |
| | | onDrawEndHandler:function(obj) |
| | | { |
| | | if(this._isDrawOnece) |
| | | { |
| | | this.deactivate(); |
| | | this.onselfDeactivate(); |
| | | } |
| | | this.onDrawEnd(obj.geometry); |
| | | }, |
| | | onDrawEnd:function(geometry) |
| | | { |
| | | return geometry; |
| | | }, |
| | | onselfDeactivate:function() |
| | | { |
| | | return this; |
| | | } |
| | | |
| | | }); |
| | | return RL; |
| | | }); |