@@ -55,9 +55,10 @@ export class MapvLayer {
5555 transferCoordinate : this . _transferCoordinate ,
5656 getCenterPixel : this . _getCenterPixel ,
5757 getResolution : this . _getResolution ,
58- validZoom : this . _validZoom
58+ validZoom : this . _validZoom . bind ( this )
5959 } , { mapElement : this . map . getCanvas ( ) , targetElement : this . mapContainer , id : this . id } ) ;
6060 this . mapContainer . style . perspective = this . map . transform . cameraToCenterDistance + 'px' ;
61+ this . bindEvent ( ) ;
6162 }
6263
6364 /**
@@ -66,14 +67,15 @@ export class MapvLayer {
6667 */
6768 onRemove ( ) {
6869 this . renderer . destroy ( ) ;
70+ this . unbindEvent ( ) ;
6971 }
7072
7173 /**
7274 * @function MapvLayer.prototype.render
7375 * @description 渲染图层。
7476 */
7577 render ( ) {
76- this . renderer . draw ( ) ;
78+ this . renderer && this . renderer . draw ( ) ;
7779 }
7880
7981 _transferCoordinate ( ) {
@@ -98,10 +100,9 @@ export class MapvLayer {
98100 }
99101
100102 _validZoom ( ) {
101- var self = this ;
102103 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 )
105106 ) {
106107 return false ;
107108 }
@@ -218,12 +219,12 @@ export class MapvLayer {
218219 */
219220 bindEvent ( ) {
220221 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 ) ;
224225 }
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 ) ;
227228 }
228229 }
229230 }
@@ -234,11 +235,11 @@ export class MapvLayer {
234235 */
235236 unbindEvent ( ) {
236237 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 ) {
239240 map . off ( 'click' , this . clickEvent ) ;
240241 }
241- if ( this . options . methods . mousemove ) {
242+ if ( this . mapvOptions . methods . mousemove ) {
242243 map . off ( 'mousemove' , this . mousemoveEvent ) ;
243244 }
244245 }
0 commit comments