filter category selector by element type
[potlatch2.git] / net / systemeD / potlatch2 / mapfeatures / MapFeatures.as
index e3a00a7180b0226335466fe9069cc580e7cc1fe2..92d72ea0312d3be8ecc0d06852584ae77cf7113d 100644 (file)
@@ -79,10 +79,25 @@ package net.systemeD.potlatch2.mapfeatures {
         [Bindable(event="featuresLoaded")]
         public function get categories():Array {
             if ( xml == null )
-                return null;            
+                return null;        
             return _categories;
         }
 
+        [Bindable(event="featuresLoaded")]
+        public function getCategoriesForType(type:String):Array {
+            if ( xml == null )
+                return null;
+            if ( type == null || type == "" )  
+                return _categories;
+                
+            var filteredCategories:Array = new Array();
+            for each( var cat:Category in _categories ) {
+                if ( cat.getFeaturesForType(type).length > 0 )
+                    filteredCategories.push(cat);
+            }
+            return filteredCategories;
+        }
+
         [Bindable(event="featuresLoaded")]
         public function get features():Array {
             if ( xml == null )