@@ -53,7 +53,7 @@ var feature = function (arg) {
5353
5454 // Don't bind handlers for improved performance on features that don't
5555 // require it.
56- if ( ! m_selectionAPI ) {
56+ if ( ! this . selectionAPI ( ) ) {
5757 return ;
5858 }
5959
@@ -413,24 +413,37 @@ var feature = function (arg) {
413413 ////////////////////////////////////////////////////////////////////////////
414414 /**
415415 * Get/Set visibility of the feature
416+ *
417+ * @param {boolean|undefined } val: undefined to return the visibility, a
418+ * boolean to change the visibility.
419+ * @param {boolean } direct: if true, when getting the visibility, disregard
420+ * the visibility of the parent layer, and when setting, refresh the state
421+ * regardless of whether it has changed or not.
422+ * @return {boolean|object } either the visibility (if getting) or the feature
423+ * (if setting).
416424 */
417425 ////////////////////////////////////////////////////////////////////////////
418- this . visible = function ( val ) {
426+ this . visible = function ( val , direct ) {
419427 if ( val === undefined ) {
428+ if ( ! direct && m_layer && m_layer . visible && ! m_layer . visible ( ) ) {
429+ return false ;
430+ }
420431 return m_visible ;
421432 }
422- if ( m_visible !== val ) {
433+ if ( m_visible !== val || direct ) {
423434 m_visible = val ;
424435 m_this . modified ( ) ;
425-
436+ if ( m_layer && m_layer . visible && ! m_layer . visible ( ) ) {
437+ val = false ;
438+ }
426439 // bind or unbind mouse handlers on visibility change
427- if ( m_visible ) {
440+ if ( val ) {
428441 m_this . _bindMouseHandlers ( ) ;
429442 } else {
430443 m_this . _unbindMouseHandlers ( ) ;
431444 }
432445 for ( var i = 0 ; i < m_dependentFeatures . length ; i += 1 ) {
433- m_dependentFeatures [ i ] . visible ( val ) ;
446+ m_dependentFeatures [ i ] . visible ( m_visible , direct ) ;
434447 }
435448 }
436449 return m_this ;
@@ -532,16 +545,26 @@ var feature = function (arg) {
532545
533546 ////////////////////////////////////////////////////////////////////////////
534547 /**
535- * Query or set if the selection API is enabled for this feature.
536- * @returns {bool }
548+ * Get/Set if the selection API is enabled for this feature.
549+ *
550+ * @param {boolean|undefined } val: undefined to return the selectionAPI
551+ * state, or a boolean to change the state.
552+ * @param {boolean } direct: if true, when getting the selectionAPI state,
553+ * disregard the state of the parent layer, and when setting, refresh the
554+ * state regardless of whether it has changed or not.
555+ * @return {boolean|object } either the selectionAPI state (if getting) or the
556+ * feature (if setting).
537557 */
538558 ////////////////////////////////////////////////////////////////////////////
539- this . selectionAPI = function ( arg ) {
559+ this . selectionAPI = function ( arg , direct ) {
540560 if ( arg === undefined ) {
561+ if ( ! direct && m_layer && m_layer . selectionAPI && ! m_layer . selectionAPI ( ) ) {
562+ return false ;
563+ }
541564 return m_selectionAPI ;
542565 }
543566 arg = ! ! arg ;
544- if ( arg !== m_selectionAPI ) {
567+ if ( arg !== m_selectionAPI || direct ) {
545568 m_selectionAPI = arg ;
546569 this . _unbindMouseHandlers ( ) ;
547570 this . _bindMouseHandlers ( ) ;
0 commit comments