zengh
2022-06-13 7973e449e74aab353d632e0db2937b376d45a6be
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/**
* 地图浏览工具的基类
* @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;
});