1
+ define ( [ "dojo/_base/declare" , "dojo/_base/lang" , "esri/geometry/Point" , "esri/geometry/ScreenPoint" ] , function ( declare , t , Point , ScreenPoint ) {
2
+ return declare ( "Echarts3Layer3x" , null , {
3
+ name : "Echarts3Layer3x" ,
4
+ _map : null ,
5
+ _ec : null ,
6
+ _geoCoord : [ ] ,
7
+ _option : null ,
8
+ _mapOffset : [ 0 , 0 ] ,
9
+ constructor : function ( map , echartsObj ) {
10
+ this . _map = map ;
11
+ var element = this . _echartsContainer = document . createElement ( "div" ) ;
12
+ element . style . position = "absolute" ,
13
+ element . style . height = map . height + "px" ,
14
+ element . style . width = map . width + "px" ,
15
+ element . style . top = 0 ,
16
+ element . style . left = 0 ,
17
+ map . __container . appendChild ( element ) ,
18
+ this . _init ( map , echartsObj )
19
+ } ,
20
+ _init : function ( map , echartsObj ) {
21
+ console . log ( '<a href="https://github.com/wandergis/arcgis-echarts3">develop by wandergis</a>' ) ;
22
+ var _self = this ;
23
+ _self . _map = map ,
24
+ _self . _ec = echartsObj ,
25
+ _self . getEchartsContainer = function ( ) {
26
+ return _self . _echartsContainer
27
+ } ,
28
+ _self . getMap = function ( ) {
29
+ return _self . _map
30
+ } ,
31
+ _self . initECharts = function ( ) {
32
+ _self . _ec = echartsObj . init . apply ( _self , arguments ) ;
33
+ _self . _ec . Geo . prototype . dataToPoint = function ( e ) {
34
+ var pointTemp = new Point ( e [ 0 ] , e [ 1 ] ) ,
35
+ pointScreenObj = _self . _map . toScreen ( pointTemp ) ;
36
+ return [ pointScreenObj . x , pointScreenObj . y ]
37
+ } ;
38
+ _self . _bindEvent ( ) ;
39
+ return _self . _ec
40
+ } ,
41
+ //_self.initECharts = function () {
42
+ // return _self._ec = echartsObj.init.apply(_self, arguments),
43
+ // _self._ec.Geo.prototype.dataToPoint = function (e) {
44
+ // var pointTemp = new Point(e[0], e[1]),
45
+ // pointScreenObj = _self._map.toScreen(pointTemp);
46
+ // return [pointScreenObj.x, pointScreenObj.y]
47
+ // },
48
+ // _self._bindEvent(),
49
+ // _self._ec
50
+ //},
51
+ _self . getECharts = function ( ) {
52
+ return _self . _ec
53
+ } ,
54
+ _self . setOption = function ( e , t ) {
55
+ _self . _option = e ,
56
+ _self . _ec . setOption ( e , t )
57
+ } ,
58
+ _self . _bindEvent = function ( ) {
59
+ _self . _map . on ( "zoom-end" , function ( e ) {
60
+ _self . _ec . resize ( ) ,
61
+ _self . _echartsContainer . style . visibility = "visible"
62
+ } ) ,
63
+ _self . _map . on ( "zoom-start" , function ( e ) {
64
+ _self . _echartsContainer . style . visibility = "hidden"
65
+ } ) ,
66
+ _self . _map . on ( "pan" , function ( e ) {
67
+ _self . _echartsContainer . style . visibility = "hidden"
68
+ } ) ,
69
+ _self . _map . on ( "pan-end" , function ( e ) {
70
+ _self . _ec . resize ( ) , _self . _echartsContainer . style . visibility = "visible"
71
+ } ) ,
72
+ _self . _map . on ( "resize" , function ( ) {
73
+ var e = _self . _echartsContainer . parentNode . parentNode . parentNode ;
74
+ _self . _mapOffset = [ - parseInt ( e . style . left ) || 0 , - parseInt ( e . style . top ) || 0 ] ,
75
+ _self . _echartsContainer . style . left = _self . _mapOffset [ 0 ] + "px" ,
76
+ _self . _echartsContainer . style . top = _self . _mapOffset [ 1 ] + "px" ,
77
+ setTimeout ( function ( ) {
78
+ _self . _map . resize ( ) , _self . _map . reposition ( ) , _self . _ec . resize ( )
79
+ } , 200 ) ,
80
+ _self . _echartsContainer . style . visibility = "visible"
81
+ } ) ,
82
+ _self . _ec . getZr ( ) . on ( "dragstart" , function ( e ) {
83
+ } ) ,
84
+ _self . _ec . getZr ( ) . on ( "dragend" , function ( e ) {
85
+ } ) ,
86
+ _self . _ec . getZr ( ) . on ( "mousewheel" , function ( e ) {
87
+ _self . _lastMousePos = _self . _map . toMap ( new ScreenPoint ( e . event . x , e . event . y ) ) ;
88
+ var t = e . wheelDelta ,
89
+ mapTemp = _self . _map ,
90
+ a = mapTemp . getZoom ( ) ;
91
+ t = t > 0 ? Math . ceil ( t ) : Math . floor ( t ) , t = Math . max ( Math . min ( t , 4 ) , - 4 ) , t = Math . max ( mapTemp . getMinZoom ( ) , Math . min ( mapTemp . getMaxZoom ( ) , a + t ) ) - a , _self . _delta = 0 , _self . _startTime = null , t && mapTemp . setZoom ( a + t )
92
+ } )
93
+ }
94
+ }
95
+ } )
96
+ } ) ;
0 commit comments