Skip to content
Snippets Groups Projects
Commit c1a49d7b authored by Peter Morstein's avatar Peter Morstein
Browse files

add layer visibility

parent 5e5fe422
No related branches found
No related tags found
No related merge requests found
export default class AvgLayer{
}
\ No newline at end of file
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<v-checkbox <v-checkbox
v-model="stationLayer" v-model="stationLayer"
hide-details hide-details
@change="layerChanged('stationLayer')" @change="$emit('layerVisibility',$event,'stationLayer')"
dense dense
> >
<template v-slot:label> <template v-slot:label>
...@@ -18,16 +18,17 @@ ...@@ -18,16 +18,17 @@
Wetterstationen Wetterstationen
</template> </template>
</v-checkbox> </v-checkbox>
<div> <div style="margin-top:1em;">
<div style="float:left;margin-top:5px;"> <div style="float:left;margin-top:5px;">
-20 °C {{parseInt(this.mapProperties.getTemperatureBound().min)}} °C
</div> </div>
<div <div
class="gradient mx-1" class="gradient mx-1"
:style="{ backgroundImage: createStationColorramp() }" :style="{ backgroundImage: createStationColorramp() }"
></div> ></div>
<div style="float:left;margin-top:5px;"> <div style="float:left;margin-top:5px;">
10 °C {{parseInt(this.mapProperties.getTemperatureBound().max)}} °C
</div> </div>
</div> </div>
...@@ -39,7 +40,7 @@ ...@@ -39,7 +40,7 @@
:max="daterange[1]" :max="daterange[1]"
thumb-label="always" thumb-label="always"
thumb-size="29px" thumb-size="29px"
style="margin-top:4em;margin-bottom:-25px;" style="margin-top:5em;margin-bottom:-25px;"
dense dense
@change="$emit('stationUpdate', $event)" @change="$emit('stationUpdate', $event)"
> >
...@@ -153,6 +154,7 @@ import {Vue, Ref, Component, Emit, Prop } from 'vue-property-decorator'; ...@@ -153,6 +154,7 @@ import {Vue, Ref, Component, Emit, Prop } from 'vue-property-decorator';
import MapProperties from './MapProperties'; import MapProperties from './MapProperties';
import { TemperatureSeries } from './StationLayer'; import { TemperatureSeries } from './StationLayer';
import TemperatureLegendChart from './TemperatureLegendChart'; import TemperatureLegendChart from './TemperatureLegendChart';
import StationLayer from './StationLayer';
@Component({}) @Component({})
export default class Legend extends Vue{ export default class Legend extends Vue{
...@@ -161,7 +163,7 @@ export default class Legend extends Vue{ ...@@ -161,7 +163,7 @@ export default class Legend extends Vue{
private layer2: boolean = true; private layer2: boolean = true;
private stationLayer: boolean = true; private stationLayer: boolean = true;
private anomalieLayer: boolean = true; private anomalieLayer: boolean = true;
private daterange: number[] = [1940, 2020]; private daterange: number[] = [1949, 2020];
private range1: number[] = [1960, 1990]; private range1: number[] = [1960, 1990];
private range2: number[] = [1991, 2020]; private range2: number[] = [1991, 2020];
private stationYear: number = 1990; private stationYear: number = 1990;
......
...@@ -5,6 +5,7 @@ export default class MapProperties{ ...@@ -5,6 +5,7 @@ export default class MapProperties{
private map: Map; private map: Map;
private projection: string; private projection: string;
private temperatureBounds: {min: number, max: number} = {min: 0, max: 0}; //min/max of all station temperature, expect for colormap
constructor(map:Map, projection: string){ constructor(map:Map, projection: string){
this.map = map; this.map = map;
...@@ -20,6 +21,14 @@ export default class MapProperties{ ...@@ -20,6 +21,14 @@ export default class MapProperties{
return icon.replace("%color%", color.replace("#", "%23")); return icon.replace("%color%", color.replace("#", "%23"));
} }
public setTemperatureBound(bound: {min: number, max: number}):void{
this.temperatureBounds = bound;
}
public getTemperatureBound():{min: number, max: number}{
return this.temperatureBounds;
}
public getZoomLevel():number{ public getZoomLevel():number{
return this.map.getView().getZoom(); return this.map.getView().getZoom();
} }
...@@ -28,4 +37,5 @@ export default class MapProperties{ ...@@ -28,4 +37,5 @@ export default class MapProperties{
return this.projection; return this.projection;
} }
} }
\ No newline at end of file
...@@ -4,7 +4,6 @@ import GeoJSON from 'ol/format/GeoJSON'; ...@@ -4,7 +4,6 @@ import GeoJSON from 'ol/format/GeoJSON';
import {Circle as CircleStyle, Fill, Stroke, Style, Text, Icon} from 'ol/style'; import {Circle as CircleStyle, Fill, Stroke, Style, Text, Icon} from 'ol/style';
import MapProperties from './MapProperties'; import MapProperties from './MapProperties';
import colormap from 'colormap'; import colormap from 'colormap';
import { timeout } from 'd3-timer';
export interface TemperatureSeries{ export interface TemperatureSeries{
date: number; date: number;
...@@ -45,14 +44,16 @@ export default class StationLayer{ ...@@ -45,14 +44,16 @@ export default class StationLayer{
if(feature.get(element)<this.allTemperatureBounds.min){ if(feature.get(element)<this.allTemperatureBounds.min){
this.allTemperatureBounds.min = feature.get(element); this.allTemperatureBounds.min = feature.get(element);
}else if(feature.get(element)>this.allTemperatureBounds.max){ }else if(feature.get(element)>this.allTemperatureBounds.max){
this.allTemperatureBounds.max = feature.get(element); this.allTemperatureBounds.max = feature.get(element) + 2;
} }
} }
}); });
}); });
this.mapProperties.setTemperatureBound(this.allTemperatureBounds);
} }
}); });
...@@ -93,7 +94,7 @@ export default class StationLayer{ ...@@ -93,7 +94,7 @@ export default class StationLayer{
image: new Icon({ image: new Icon({
crossOrigin: 'anonymous', crossOrigin: 'anonymous',
imgSize: [24, 24], imgSize: [24, 24],
scale: this.mapProperties.getZoomLevel() * 0.1, scale: this.mapProperties.getZoomLevel() * 0.15,
src: this.mapProperties.getTemperatureIcon(iconColor) src: this.mapProperties.getTemperatureIcon(iconColor)
}) })
}); });
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<template> <template>
<div id="weatherContainer"> <div id="weatherContainer">
<Legend id="legend" @stationUpdate="stationupdate" :mapProperties="mapProperties"></Legend> <Legend id="legend" @stationUpdate="stationupdate" @layerVisibility="layerVisibility" :mapProperties="mapProperties"></Legend>
<div ref="weathermap" id="weathermap" /> <div ref="weathermap" id="weathermap" />
...@@ -80,7 +80,7 @@ ...@@ -80,7 +80,7 @@
</style> </style>
<script lang="ts"> <script lang="ts">
import {Vue, Ref, Component } from 'vue-property-decorator'; import {Vue, Ref, Component, Watch } from 'vue-property-decorator';
import View from 'ol/View'; import View from 'ol/View';
import Map from 'ol/Map'; import Map from 'ol/Map';
import OSM from 'ol/source/OSM'; import OSM from 'ol/source/OSM';
...@@ -126,8 +126,8 @@ export default class WeatherMap extends Vue{ ...@@ -126,8 +126,8 @@ export default class WeatherMap extends Vue{
}) })
], ],
view: new View({ view: new View({
zoom: 6.45, zoom: 6.49,
center: fromLonLat([11, 51.3]), center: fromLonLat([4.0, 51.3]),
constrainResolution: true, constrainResolution: true,
projection: this.projection projection: this.projection
}), }),
...@@ -135,8 +135,7 @@ export default class WeatherMap extends Vue{ ...@@ -135,8 +135,7 @@ export default class WeatherMap extends Vue{
}); });
this.mapProperties = new MapProperties(this.map, this.projection); this.mapProperties = new MapProperties(this.map, this.projection);
this.appendStationLayer(); this.appendStationLayer();
this.map.on('click', (evt) => { this.map.on('click', (evt) => {
...@@ -182,6 +181,14 @@ export default class WeatherMap extends Vue{ ...@@ -182,6 +181,14 @@ export default class WeatherMap extends Vue{
this.stationLayer.newYear(event); this.stationLayer.newYear(event);
} }
protected layerVisibility(isVisible: boolean, layer:string):void{
//this.stationLayer.getLayer().setVisible(this.visibleLayers.has(StationLayer.layerName));
if(layer=='stationLayer'){
this.stationLayer.getLayer().setVisible(isVisible);
}
}
}; };
</script> </script>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment