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
				
			
		| 
						 | 
					@ -20,7 +20,7 @@ export default class AllKnownLayers {
 | 
				
			||||||
    public static sharedLayersJson: Map<string, any> = AllKnownLayers.getSharedLayersJson();
 | 
					    public static sharedLayersJson: Map<string, any> = AllKnownLayers.getSharedLayersJson();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static added_by_default: string[] = ["gps_location", "gps_location_history", "home_location", "gps_track",]
 | 
					    public static added_by_default: string[] = ["gps_location", "gps_location_history", "home_location", "gps_track","current_view"]
 | 
				
			||||||
    public static no_include: string[] = ["conflation", "left_right_style", "split_point"]
 | 
					    public static no_include: string[] = ["conflation", "left_right_style", "split_point"]
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Layer IDs of layers which have special properties through built-in hooks
 | 
					     * Layer IDs of layers which have special properties through built-in hooks
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,6 +17,7 @@ import {FeatureSourceForLayer, Tiled} from "../FeatureSource/FeatureSource";
 | 
				
			||||||
import SimpleFeatureSource from "../FeatureSource/Sources/SimpleFeatureSource";
 | 
					import SimpleFeatureSource from "../FeatureSource/Sources/SimpleFeatureSource";
 | 
				
			||||||
import {LocalStorageSource} from "../Web/LocalStorageSource";
 | 
					import {LocalStorageSource} from "../Web/LocalStorageSource";
 | 
				
			||||||
import {GeoOperations} from "../GeoOperations";
 | 
					import {GeoOperations} from "../GeoOperations";
 | 
				
			||||||
 | 
					import StaticFeatureSource from "../FeatureSource/Sources/StaticFeatureSource";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Contains all the leaflet-map related state
 | 
					 * Contains all the leaflet-map related state
 | 
				
			||||||
| 
						 | 
					@ -44,11 +45,12 @@ export default class MapState extends UserRelatedState {
 | 
				
			||||||
        lon: number;
 | 
					        lon: number;
 | 
				
			||||||
    }> = new UIEventSource<{ lat: number; lon: number }>(undefined);
 | 
					    }> = new UIEventSource<{ lat: number; lon: number }>(undefined);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public currentView: FeatureSourceForLayer
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * The location as delivered by the GPS
 | 
					     * The location as delivered by the GPS
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public currentUserLocation: FeatureSourceForLayer & Tiled;
 | 
					    public currentUserLocation: FeatureSourceForLayer & Tiled;
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * All previously visited points
 | 
					     * All previously visited points
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
| 
						 | 
					@ -125,6 +127,7 @@ export default class MapState extends UserRelatedState {
 | 
				
			||||||
        this.initHomeLocation()
 | 
					        this.initHomeLocation()
 | 
				
			||||||
        this.initGpsLocation()
 | 
					        this.initGpsLocation()
 | 
				
			||||||
        this.initUserLocationTrail()
 | 
					        this.initUserLocationTrail()
 | 
				
			||||||
 | 
					        this.initCurrentView()
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public AddAllOverlaysToMap(leafletMap: UIEventSource<any>) {
 | 
					    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() {
 | 
					    private initGpsLocation() {
 | 
				
			||||||
        // Initialize the gps layer data. This is emtpy for now, the actual writing happens in the Geolocationhandler
 | 
					        // Initialize the gps layer data. This is emtpy for now, the actual writing happens in the Geolocationhandler
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,3 +1,14 @@
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					  "id": "current_view",
 | 
				
			||||||
 | 
					  "description": "A meta-layer which contains one single feature, namely the BBOX of the current map view. This can be used to trigger special actions. If a popup is defined for this layer, this popup will be accessible via an extra button on screen",
 | 
				
			||||||
 | 
					  "source": {
 | 
				
			||||||
 | 
					    "osmTags": "id=currentView"
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  "title": "Current View",
 | 
				
			||||||
 | 
					  "tagRenderings": [],
 | 
				
			||||||
 | 
					  "mapRendering": [
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      "color": "#cccc0088"
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  ]
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue