File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -160,6 +160,26 @@ class Layer extends JSONAble(Eventable(Renderable(Class))) {
160160 return this . _zIndex || 0 ;
161161 }
162162
163+ /**
164+ * Get Layer's minZoom to display
165+ * @return {Number }
166+ */
167+ getMinZoom ( ) {
168+ const map = this . getMap ( ) ;
169+ const minZoom = this . options [ 'minZoom' ] ;
170+ return map ? Math . max ( map . getMinZoom ( ) , minZoom || 0 ) : minZoom ;
171+ }
172+
173+ /**
174+ * Get Layer's maxZoom to display
175+ * @return {Number }
176+ */
177+ getMaxZoom ( ) {
178+ const map = this . getMap ( ) ;
179+ const maxZoom = this . options [ 'maxZoom' ] ;
180+ return map ? Math . min ( map . getMaxZoom ( ) , isNil ( maxZoom ) ? Infinity : maxZoom ) : maxZoom ;
181+ }
182+
163183 /**
164184 * Get layer's opacity
165185 * @returns {Number }
Original file line number Diff line number Diff line change @@ -84,6 +84,16 @@ describe('Layer.Spec', function () {
8484 } ) ;
8585 } ) ;
8686
87+ it ( '#getMinZoom and #getMaxZoom' , function ( ) {
88+ var layer = new maptalks . VectorLayer ( '1' , {
89+ minZoom : 10
90+ } ) ;
91+
92+ map . addLayer ( layer ) ;
93+ expect ( layer . getMinZoom ( ) ) . to . be . eql ( 10 ) ;
94+ expect ( layer . getMaxZoom ( ) ) . to . be . eql ( map . getMaxZoom ( ) ) ;
95+ } ) ;
96+
8797 describe ( 'zindex of layers' , function ( ) {
8898 it ( 'default zindex is 0' , function ( ) {
8999 var layer1 = new maptalks . TileLayer ( '1' , { renderer :'canvas' } ) ;
You can’t perform that action at this time.
0 commit comments