@@ -55,9 +55,10 @@ export class MapvLayer {
55
55
transferCoordinate : this . _transferCoordinate ,
56
56
getCenterPixel : this . _getCenterPixel ,
57
57
getResolution : this . _getResolution ,
58
- validZoom : this . _validZoom
58
+ validZoom : this . _validZoom . bind ( this )
59
59
} , { mapElement : this . map . getCanvas ( ) , targetElement : this . mapContainer , id : this . id } ) ;
60
60
this . mapContainer . style . perspective = this . map . transform . cameraToCenterDistance + 'px' ;
61
+ this . bindEvent ( ) ;
61
62
}
62
63
63
64
/**
@@ -66,14 +67,15 @@ export class MapvLayer {
66
67
*/
67
68
onRemove ( ) {
68
69
this . renderer . destroy ( ) ;
70
+ this . unbindEvent ( ) ;
69
71
}
70
72
71
73
/**
72
74
* @function MapvLayer.prototype.render
73
75
* @description 渲染图层。
74
76
*/
75
77
render ( ) {
76
- this . renderer . draw ( ) ;
78
+ this . renderer && this . renderer . draw ( ) ;
77
79
}
78
80
79
81
_transferCoordinate ( ) {
@@ -98,10 +100,9 @@ export class MapvLayer {
98
100
}
99
101
100
102
_validZoom ( ) {
101
- var self = this ;
102
103
if (
103
- ( self . options . minZoom && this . map . getZoom ( ) < self . options . minZoom ) ||
104
- ( self . options . maxZoom && this . map . getZoom ( ) > self . options . maxZoom )
104
+ ( this . mapVOptions . minZoom && this . map . getZoom ( ) < this . mapVOptions . minZoom ) ||
105
+ ( this . mapVOptions . maxZoom && this . map . getZoom ( ) > this . mapVOptions . maxZoom )
105
106
) {
106
107
return false ;
107
108
}
@@ -218,12 +219,12 @@ export class MapvLayer {
218
219
*/
219
220
bindEvent ( ) {
220
221
var map = this . map ;
221
- if ( this . options . methods ) {
222
- if ( this . options . methods . click ) {
223
- map . on ( 'click' , this . clickEvent ) ;
222
+ if ( this . mapVOptions . methods ) {
223
+ if ( this . mapVOptions . methods . click ) {
224
+ map . on ( 'click' , this . renderer . clickEvent ) ;
224
225
}
225
- if ( this . options . methods . mousemove ) {
226
- map . on ( 'mousemove' , this . mousemoveEvent ) ;
226
+ if ( this . mapVOptions . methods . mousemove ) {
227
+ map . on ( 'mousemove' , this . renderer . mousemoveEvent ) ;
227
228
}
228
229
}
229
230
}
@@ -234,11 +235,11 @@ export class MapvLayer {
234
235
*/
235
236
unbindEvent ( ) {
236
237
var map = this . map ;
237
- if ( this . options . methods ) {
238
- if ( this . options . methods . click ) {
238
+ if ( this . mapvOptions . methods ) {
239
+ if ( this . mapvOptions . methods . click ) {
239
240
map . off ( 'click' , this . clickEvent ) ;
240
241
}
241
- if ( this . options . methods . mousemove ) {
242
+ if ( this . mapvOptions . methods . mousemove ) {
242
243
map . off ( 'mousemove' , this . mousemoveEvent ) ;
243
244
}
244
245
}
0 commit comments