Is there any way of making the feature filter a select list instead of check boxes?
someone has managed to achieve it on here http://jsfiddle.net/doktormolle/HKUrf/

Comments

tmptye’s picture

More to the point is there ANY way to make the feature filter list work?

eurotrash’s picture

An ugly hack but it works.
I ended up rebuilding the script uncompressed and applying the solution in the fiddle above.

Full File
https://gist.github.com/tedgeving/9bf543de968841b79d90

if (this.settings_['featureFilter']) {
    // TODO(cbro): update this on view_changed
    
   /* var features = view.getFeatures().asList(),
        //createe a select-element on the fly using jQuery
        list = $('<select/>')
        //put it somewhere, here it will be appended 
        //to the form created by the storeLocator
            .appendTo('#panel .storelocator-filter').
        //apply the change-handler for the select
        change(function () {
            view.set('featureFilter',
            new storeLocator.FeatureSet(features[this.selectedIndex]));
            view.refreshView();
        });
    //populate the  select with options
    $.each(features, function (i, o) {

        list.append(new Option(o.getDisplayName()));

    }); */

    this.featureFilter_ = $('<div class="feature-filter"/>');    
    var allFeatures = this.get('view').getFeatures().asList();
       list = $('<select/>')
        //put it somewhere, here it will be appended 
        //to the form created by the storeLocator
            .appendTo(this.featureFilter_).
        //apply the change-handler for the select
        change(function () {
          
          console.log(allFeatures[this.selectedIndex]);  

          if(allFeatures[this.selectedIndex] == 'null'){
             this.get('view').refreshView();
             console.log('refresh');
          }else{

           that.get('view').set('featureFilter',
            new storeLocator.FeatureSet(allFeatures[this.selectedIndex]));
           that.get('view').refreshView();
         }
        });

         /// list.append('<option value="null" >NULL</option>');
        $.each(allFeatures, function (i, o) {
          //o.getDisplayName()
        list.append('<option value="'+o.getDisplayName() +'"' +' >'+o.getDisplayName()+'</option>');

    }); 

/*
    for (var i = 0, ii = allFeatures.length; i < ii; i++) {
      var feature = allFeatures[i];
      
      var checkbox = $('<input type="checkbox"/>');
      
      checkbox.data('feature', feature);
      $('<label/>').append(checkbox).append(feature.getDisplayName())
        .appendTo(this.featureFilter_);
      }
  */


     this.filter_.append(this.featureFilter_);
    /*
    this.featureFilter_.find('input').change(function() {
      var feature = $(this).data('feature');
      that.toggleFeatureFilter_((feature));
      that.get('view').refreshView();
    });  */

}

rodrigoeg’s picture

Category: Support request » Feature request