@@ -138,6 +138,11 @@ module.exports = (function () {
138
138
*/
139
139
//////////////////////////////////////////////////////////////////////////////
140
140
var tileLayer = function ( options ) {
141
+ 'use strict' ;
142
+ if ( ! ( this instanceof tileLayer ) ) {
143
+ return new tileLayer ( options ) ;
144
+ }
145
+ featureLayer . call ( this , options ) ;
141
146
142
147
var $ = require ( 'jquery' ) ;
143
148
var geo_event = require ( './event' ) ;
@@ -147,11 +152,6 @@ module.exports = (function () {
147
152
var adjustLayerForRenderer = require ( './registry' ) . adjustLayerForRenderer ;
148
153
var Tile = require ( './tile' ) ;
149
154
150
- if ( ! ( this instanceof tileLayer ) ) {
151
- return new tileLayer ( options ) ;
152
- }
153
- featureLayer . call ( this , options ) ;
154
-
155
155
options = $ . extend ( true , { } , this . constructor . defaults , options || { } ) ;
156
156
if ( ! options . cacheSize ) {
157
157
// this size should be sufficient for a 4k display
@@ -177,6 +177,7 @@ module.exports = (function () {
177
177
178
178
var s_init = this . _init ,
179
179
s_exit = this . _exit ,
180
+ s_visible = this . visible ,
180
181
m_lastTileSet = [ ] ,
181
182
m_maxBounds = [ ] ,
182
183
m_exited ;
@@ -1063,6 +1064,9 @@ module.exports = (function () {
1063
1064
evt . event . event === geo_event . rotate ) ) {
1064
1065
return ;
1065
1066
}
1067
+ if ( ! this . visible ( ) ) {
1068
+ return ;
1069
+ }
1066
1070
var map = this . map ( ) ,
1067
1071
bounds = map . bounds ( undefined , null ) ,
1068
1072
mapZoom = map . zoom ( ) ,
@@ -1430,6 +1434,30 @@ module.exports = (function () {
1430
1434
return m_tileOffsetValues [ level ] ;
1431
1435
} ;
1432
1436
1437
+ ////////////////////////////////////////////////////////////////////////////
1438
+ /**
1439
+ * Get/Set visibility of the layer
1440
+ *
1441
+ * @param {boolean|undefined } val: undefined to return the visibility, a
1442
+ * boolean to change the visibility.
1443
+ * @return {boolean|object } either the visibility (if getting) or the layer
1444
+ * (if setting).
1445
+ */
1446
+ ////////////////////////////////////////////////////////////////////////////
1447
+ this . visible = function ( val ) {
1448
+ if ( val === undefined ) {
1449
+ return s_visible ( ) ;
1450
+ }
1451
+ if ( this . visible ( ) !== val ) {
1452
+ s_visible ( val ) ;
1453
+
1454
+ if ( val ) {
1455
+ this . _update ( ) ;
1456
+ }
1457
+ }
1458
+ return this ;
1459
+ } ;
1460
+
1433
1461
/**
1434
1462
* Initialize after the layer is added to the map.
1435
1463
*/
0 commit comments