First attempt for a current-view box

This commit is contained in:
Pieter Vander Vennet 2021-12-10 15:51:08 +01:00
parent ee3a18def1
commit dc5b777713
3 changed files with 45 additions and 3 deletions

View file

@ -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