forked from MapComplete/MapComplete
		
	Add switch to hide certain features, cleanup of code
This commit is contained in:
		
							parent
							
								
									aa0989b72a
								
							
						
					
					
						commit
						1b1ec9f15d
					
				
					 18 changed files with 230 additions and 173 deletions
				
			
		
							
								
								
									
										30
									
								
								Logic/FeatureSource/MetaTaggingFeatureSource.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								Logic/FeatureSource/MetaTaggingFeatureSource.ts
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,30 @@ | |||
| import FeatureSource from "./FeatureSource"; | ||||
| import {UIEventSource} from "../UIEventSource"; | ||||
| import State from "../../State"; | ||||
| import Hash from "../Web/Hash"; | ||||
| import MetaTagging from "../MetaTagging"; | ||||
| 
 | ||||
| export default class MetaTaggingFeatureSource implements FeatureSource { | ||||
|     features: UIEventSource<{ feature: any; freshness: Date }[]> = new UIEventSource<{feature: any; freshness: Date}[]>(undefined); | ||||
|      | ||||
|     constructor(source: FeatureSource) { | ||||
|         const self = this; | ||||
|         source.features.addCallbackAndRun((featuresFreshness: { feature: any, freshness: Date }[]) => { | ||||
|                 if (featuresFreshness === undefined) { | ||||
|                     return; | ||||
|                 } | ||||
|                 featuresFreshness.forEach(featureFresh => { | ||||
|                     const feature = featureFresh.feature; | ||||
|                     State.state.allElements.addOrGetElement(feature); | ||||
| 
 | ||||
|                     if (Hash.hash.data === feature.properties.id) { | ||||
|                         State.state.selectedElement.setData(feature); | ||||
|                     } | ||||
|                 }) | ||||
| 
 | ||||
|                 MetaTagging.addMetatags(featuresFreshness, State.state.layoutToUse.data.layers); | ||||
|                 self.features.setData(featuresFreshness); | ||||
|         }); | ||||
|     } | ||||
|      | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue