forked from MapComplete/MapComplete
		
	First attempt for a current-view box
This commit is contained in:
		
							parent
							
								
									ee3a18def1
								
							
						
					
					
						commit
						dc5b777713
					
				
					 3 changed files with 45 additions and 3 deletions
				
			
		|  | @ -17,6 +17,7 @@ import {FeatureSourceForLayer, Tiled} from "../FeatureSource/FeatureSource"; | |||
| import SimpleFeatureSource from "../FeatureSource/Sources/SimpleFeatureSource"; | ||||
| import {LocalStorageSource} from "../Web/LocalStorageSource"; | ||||
| import {GeoOperations} from "../GeoOperations"; | ||||
| import StaticFeatureSource from "../FeatureSource/Sources/StaticFeatureSource"; | ||||
| 
 | ||||
| /** | ||||
|  * Contains all the leaflet-map related state | ||||
|  | @ -44,11 +45,12 @@ export default class MapState extends UserRelatedState { | |||
|         lon: number; | ||||
|     }> = new UIEventSource<{ lat: number; lon: number }>(undefined); | ||||
| 
 | ||||
|     public currentView: FeatureSourceForLayer | ||||
|     /** | ||||
|      * The location as delivered by the GPS | ||||
|      */ | ||||
|     public currentUserLocation: FeatureSourceForLayer & Tiled; | ||||
| 
 | ||||
|      | ||||
|     /** | ||||
|      * All previously visited points | ||||
|      */ | ||||
|  | @ -125,6 +127,7 @@ export default class MapState extends UserRelatedState { | |||
|         this.initHomeLocation() | ||||
|         this.initGpsLocation() | ||||
|         this.initUserLocationTrail() | ||||
|         this.initCurrentView() | ||||
|     } | ||||
| 
 | ||||
|     public AddAllOverlaysToMap(leafletMap: UIEventSource<any>) { | ||||
|  | @ -169,6 +172,34 @@ export default class MapState extends UserRelatedState { | |||
|             }) | ||||
|         } | ||||
|     } | ||||
|      | ||||
|     private initCurrentView(){ | ||||
|         const features : UIEventSource<{ feature: any, freshness: Date }[]>= this.currentBounds.map(bounds => { | ||||
|             const feature = { | ||||
|                 freshness: new Date(), | ||||
|                 feature: { | ||||
|                     type: "Polygon", | ||||
|                     properties:{ | ||||
|                         id:"current_view" | ||||
|                     }, | ||||
|                     geometry:{ | ||||
|                         type:"Polygon", | ||||
|                         coordinates:[ | ||||
|                             [bounds.maxLon, bounds.maxLat], | ||||
|                             [bounds.minLon, bounds.maxLat], | ||||
|                             [bounds.minLon, bounds.minLat], | ||||
|                             [bounds.maxLon, bounds.minLat], | ||||
|                             [bounds.maxLon, bounds.maxLat], | ||||
|                         ] | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|             return [feature] | ||||
|         }) | ||||
|         let currentViewLayer: FilteredLayer = this.filteredLayers.data.filter(l => l.layerDef.id === "current_view")[0] | ||||
| 
 | ||||
|         this.currentView = new SimpleFeatureSource(currentViewLayer,0,features) | ||||
|     } | ||||
| 
 | ||||
|     private initGpsLocation() { | ||||
|         // Initialize the gps layer data. This is emtpy for now, the actual writing happens in the Geolocationhandler
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue