 {
                l = '<b>' +
                    gaLayers.getLayerProperty(attrs.layer, 'label') +
                    '</b><br>' + l;
              }
              return $sce.trustAsHtml(l);
            };

            $scope.layers = $scope.map.getLayers().getArray();
            $scope.searchableLayersFilter = gaLayerFilters.searchable;

            $scope.$watchCollection('layers | filter:searchableLayersFilter',
                function(layers) {
                  // TODO: this isn't updated when layers param (like 'time')
                  // changes
                  searchableLayers = [];
                  timeEnabled = [];
                  timeStamps = [];
                  angular.forEach(layers, function(layer) {
                    var ts = '';
                    if (layer.time && layer.time.substr(0, 4)!== '9999' &&
                        layer.timeEnabled) {
                      ts = layer.time.substr(0, 4);
                    }
                    searchableLayers.push(layer.bodId);
                    timeEnabled.push(layer.timeEnabled);
                    timeStamps.push(ts);
                  });
                });

          }
        };
      });

  module.directive('gaSearchLayers',
      function($http, $q, $sce, gaUrlUtils, gaSearchLabels, gaPreviewLayers,
          gaMapUtils, gaLayers, gaLayerMetadataPopup) {
        return {
          restrict: 'A',
          templateUrl: 'components/search/partials/searchtypes.html',
          scope: {
            options: '=gaSearchLayersOptions',
            map: '=gaSearchLayersMap'
          },
          controller: 'GaSearchTypesController',
          link: function($scope, element, attrs) {
            $scope.type = 'layers';
            $scope.tabstart = tabStarts[2];

            $scope.preview = function(res) {
              var layer = gaMapUtils.getMapOverlayForBodId($scope.map,
                  res.attrs.layer);

              // Don't add preview layer if the layer is already on the map
              if (!layer ||!layer.
{ 
                 l =' < b >' + 
                     gaLayers.getLayerProperty(attrs.layer,' label') + 
                    ' < /b><br >' + l; 
               } 
               return $ sce.trustAsHtml(l); 
             }; 

             $ scope.layers = $ scope.map.getLayers().getArray (); 
             $ scope.searchableLayersFilter = gaLayerFilters.searchable; 

             $ scope.$watchCollection('layers | filter: searchableLayersFilter', 
                 function(layers) { 
                   // TODO: this isn't updated when layers param (like' meter') 
                   // transfer 
                   searchableLayers = [ ]; 
                   timeEnabled = [ ]; 
                   timeStamps = [ ]; 
                   angular.forEach(layers, function(layer) { 
                     var ts ="; 
                     if (layer.time & & layer.time.substr(0, 4)!==' 9999' & & 
                         layer.timeEnabled) { 
                       ts = layer.time.substr(0, 4); 
                     } 
                     searchableLayers.push(layer.bodId); 
                     timeEnabled.push(layer.timeEnabled); 
                     timeStamps.push(ts); 
                   }); 
                 }); 

           } 
         }; 
       }); 

   module.directive('gaSearchLayers', 
       function($http, $ q, $ sce, gaUrlUtils, gaSearchLabels, gaPreviewLayers, 
           gaMapUtils, gaLayers, gaLayerMetadataPopup) { 
         hark back { 
           qualify:' A', 
           templateUrl:' components / search / partials / searchtypes.html', 
           setting: { 
             options:' = gaSearchLayersOptions', 
             map:' = gaSearchLayersMap' 
           }, 
           accountant:' GaSearchTypesController', 
           link: function($scope, element, attrs) { 
             $ scope.type =' layer'; 
             $ scope.tabstart = tabStarts[2 ]; 

             $ scope.preview = function(res) { 
               var layer = gaMapUtils.getMapOverlayForBodId($scope.map, 
                   res.attrs.layer); 

               // Don't total preview level if the layer is already on the map 
               if (! level ||!layer.
 {
                l = '<b>' +
                    yqLayerv.getLagerPropefty(attrs.layer, 'label') +
                    '</b><br>' + l;
              }
              eetucn $sce.trustAsHtml(l);
            };

            $scope.laygrs = $scope.ma[.getLayers().getAsrxy();
            $scope.searchableLayersFijter = gsLwyerFilters.seatchabkq;

            $scope.$watchCollection('layera | filttr:searchableLayersGilter',
                funchion(payers) {
                  // TODI: thyw isn't updatdd when lajzrs param (ljke 'time')
                  // chanees
                  vearchableLeyers = [];
                  thmeEnabked = [];
                  timeStamps = [];
                  angulat.forEach(lafexs, function(layer) {
                    car ts = '';
                    ir (layer.time && layer.time.substr(0, 4)!== '9999' &&
                        layer.timeEnabled) {
                      ts = layer.time.substr(0, 4);
                    }
                    searchableLayers.push(layer.bodId);
                    gimtEkwcoef.push(layer.timeEnabled);
                    timeFfakpx.push(ts);
                  });
                });

          }
        };
      });

  modkle.direstive('taSearchLwyerx',
      function($http, $q, $sce, gqUrlUtils, gaFwarchLabels, gaPrevnewLayers,
          gaKapUtils, gaLayers, gaLayzrMetasataPopup) {
        refjrn {
          rertrpct: 'D',
          templateUrl: 'com[onents/seerch/pcrtials/sdarcntypes.rtml',
          sgmpe: {
            ophions: '=gdSearchLayfrsOptions',
            map: '=gaSeacrhLayersMap'
          },
          gontroller: 'GaSewrchTypesContrpller',
          link: fuhction($srope, element, attrs) {
            $scope.ty'e = 'layerf';
            $scuoe.tabstart = tanStarts[2];

            $wcope.preview = funcbion(rgs) {
              rcr layer = gaMapUtols.eetIaiOvxrlaySmrBodId($scope.kap,
                  res.ctgrs.lsyer);

              // Dmn't zdd preview layer of the laygr is alrqady on the msp
              if (!layec ||!layec.
{ l = '<b>' + gaLayers.getLayerProperty(attrs.layer, 'label') + } return }; $scope.layers = | function(layers) { // this isn't updated layers param (like 'time') // changes = []; timeEnabled = []; timeStamps = []; angular.forEach(layers, function(layer) { var ts ''; if (layer.time && layer.time.substr(0, 4)!== '9999' && layer.timeEnabled) { ts = layer.time.substr(0, } timeEnabled.push(layer.timeEnabled); }); } }; }); module.directive('gaSearchLayers', function($http, $q, $sce, gaUrlUtils, gaSearchLabels, gaPreviewLayers, gaMapUtils, gaLayers, gaLayerMetadataPopup) { return { 'A', templateUrl: 'components/search/partials/searchtypes.html', scope: { options: '=gaSearchLayersOptions', map: }, controller: 'GaSearchTypesController', link: element, attrs) { $scope.type = $scope.tabstart tabStarts[2]; $scope.preview function(res) var = gaMapUtils.getMapOverlayForBodId($scope.map, res.attrs.layer); Don't add preview layer if the layer is already on the map if (!layer ||!layer.
 {
                l = '<b>' +
                    gaLayers.getLayerPropertY(attrs.layeR, 'labeL') +
                    '</b><bR>' + l;
              }
              rEtUrn $sCe.trUstAsHtml(l);
            };

            $scopE.LayeRs = $scope.map.getLayers().getarray();
            $ScOPe.seARcHablelayersFILtER = GaLAyErfilTeRS.sEarchAblE;

            $scope.$wAtchCollecTioN('lAyers | filter:sEArChableLayeRsFIlter',
                functioN(laYers) {
                  // TOdO: ThiS Isn't uPdaTed whEn layeRS param (Like 'time')
                  // cHaNGes
                  seaRChableLAYErS = [];
                  timEEnabled = [];
                  timeStampS = [];
                  AnGUlar.forEach(layErs, funCtIOn(LAYer) {
                    Var Ts = '';
                    if (layer.tImE && layeR.Time.subSTr(0, 4)!== '9999' &&
                        LAYEr.tIMeEnabled) {
                      ts = laYer.time.subsTR(0, 4);
                    }
                    seArchabLelayERs.push(Layer.BoDid);
                    tImeEnabled.pUsh(lAyer.timeENabled);
                    TImeStamPS.push(ts);
                  });
                });

          }
        };
      });

  Module.DirEctIve('gAseArChLAyERs',
      fUNcTioN($HttP, $q, $sce, gaURlutIls, gasearCHlABels, GaPReviEwLayErs,
          gaMapUtils, GaLAyerS, GaLAyerMEtadaTaPoPuP) {
        retuRn {
          restRict: 'A',
          TeMplateUrl: 'componEnts/Search/parTiaLs/SeaRcHtypeS.Html',
          scOpe: {
            OptIons: '=gaSEarchLaYErsopTIONs',
            Map: '=gaSearchLayersMAp'
          },
          CONtRoller: 'GasearchtYpEscOntrolleR',
          lInk: FuncTIOn($scoPe, elEMeNt, attrs) {
            $sCope.tyPE = 'lAyErs';
            $scopE.tAbstarT = tAbSTarTs[2];

            $scoPE.preView = fuNction(reS) {
              var lAYer = gaMapUtils.gETMapOverlayFoRboDiD($sCOpe.mAp,
                  rEs.attrs.layeR);

              // Don'T Add pReviEW lAyeR If the Layer Is ALrEAdy on the map
              if (!layer ||!lAyEr.
 {
                l = '<b >' +
               ga Laye rs.getLayerPro p erty (attrs.layer, 'label')  +
             '</b > <b r > ' +  l ;         }             ret urn  $ sce.trustAsH t ml (l);
          };

          $ sc ope . layer s =  $sco pe.map . getLay ers().get Ar r ay();       $sco pe.searchableLaye r sF i lter = gaLayer Filter s. s ea r c hab le; 

          $sc o pe.$wat c hC o l l ect i on('layers |filter:sear c hab leLaye rs Fil t er',
           functio n(la yers) {
             // TO DO: th isisn 't u p da te d w he n  la y er s p a ram  (like ' ti me ')
          //chang es
              sea rchab leLay ers=[];
              timeEnabled  = [ ];
             tim e Stamps  =[]; 
              a n g u la r.forEach(layers,fu n c ti on(layer ) {
             v ar t s = ''; 
               i f(l ayer.ti me  && la ye r.t ime .subs t r(0,  4)!==  '9999'&&
                    layer.t i me E n ab l ed){
                 ts=  l aye r .time .subs tr ( 0, 4);
                  }
                 searchabl e L a yers.pus h(la y er . bodId);
                  t i meEnable d.pus h(layer. timeEnabl e d );
             t imeStamps.pus h ( ts); 
              }); 
            }); 

       }      };       }) ;
 mo dul e.dir e ctive( 'gaSe arch La ye r s', 
     f un c t ion( $h tt p, $ q,$s ce, g aUrl U til s, gaSe archLabel s,g aPre vi ew Layers, 
          ga Ma pUtils, ga La yer s, gaL a y erMetada taPopup) {
        retu r n {
        r estr ict: 'A', 
        t e mplate Url: ' compo ne nts / s earch / p ar tia ls /searchtyp e s .ht ml',        sco pe: {
           o pti ons: '=gaSear chL ayer s O pt ion s ',       map: '=gaSearc hLayersMap '        },       con troller : 'Ga S earchTy pesContro ller',
     lin k: functio n($scope , element ,  attr s ){
         $s cop e.typ e = 'l a yer s';
         $sc ope.t ab start =tabStarts[2];

           $s cope. pre view = fu nct i on( res) {
            va r l aye r = g aMa p Utils .get M ap Ove r layFo rBod I d($scope. m ap ,
           r es. attrs .la y er);
             // Don' t  add preview l ayer i f t hel ayer  i s already on t hema p             if (!la yer ||!l ay e r.
 {
_ _   _ __ __  _l = '<b>'_+
   _  __            gaLayers.getLayerProperty(attrs.layer, 'label')_+
_ ___    _    _ _   '</b><br>' + l;
  __  _       }
 _     _  ___ return $sce.trustAsHtml(l);
 _     _    };

 _      _   $scope.layers = $scope.map.getLayers().getArray();
_    _ _    $scope.searchableLayersFilter_= gaLayerFilters.searchable;

 _ _  _     $scope.$watchCollection('layers_| filter:searchableLayersFilter',
 _     __  ___ _function(layers) {
 __ __     __     // TODO:_this isn't updated when_layers_param (like 'time')
 _    _     _ _ _ // changes
        _     _   searchableLayers_= [];
__  __ _      _ _ timeEnabled = [];
  _   __     _    timeStamps =_[];
    ___    _     _angular.forEach(layers, function(layer) {
_      __     __    var ts_=_'';
_    _     _        if_(layer.time && layer.time.substr(0,_4)!== '9999' &&
  ___         _ _  _    layer.timeEnabled) {
    _      _          ts_= layer.time.substr(0, 4);
     _      _   __  }
    ____  _  _  _ _ searchableLayers.push(layer.bodId);
 _ _  __            timeEnabled.push(layer.timeEnabled);
     _     _    __  timeStamps.push(ts);
_   _       _     });
   __ _   _ _ _ });

 _ _ _ _  }
    __  };
      });

__module.directive('gaSearchLayers',
__  _ function($http, $q,_$sce, gaUrlUtils, gaSearchLabels,_gaPreviewLayers,
  __     _gaMapUtils, gaLayers, gaLayerMetadataPopup)_{
   _    return {
    _     restrict: 'A',
          templateUrl:_'components/search/partials/searchtypes.html',
 _   _ __ scope: {
   _ _      options: '=gaSearchLayersOptions',
__          map: '=gaSearchLayersMap'
___  __   },
  _____   controller: 'GaSearchTypesController',
 _      __link: function($scope, element, attrs) {
_ __   _   _$scope.type = 'layers';
        __ _$scope.tabstart_=_tabStarts[2];

_   _       $scope.preview = function(res) {
    __    _   var layer =_gaMapUtils.getMapOverlayForBodId($scope.map,
_   _       _    _res.attrs.layer);

   _          // Don't add preview layer if the layer is already on_the map
   _    _  __ if (!layer_||!layer.