Newer
Older
<Legend id="legend" @stationUpdate="stationupdate" @layerVisibility="layerVisibility" @calculateAnomalie="calculateAnomalie" :mapProperties="mapProperties"></Legend>
<div ref="popup" class="ol-popup">
<a href="#" ref="popup-closer" class="ol-popup-closer"></a>
<div ref="popup-content">
</div>
<StationChartPopup ref="StationChartPopup"/>
</div>
#weatherContainer{
width:100%;
height:100%;
position:relative;
}
#legend{
width:20%;
height:100%;
position:relative;
float:right;
}
#weathermap{
width:80%;
height:100%;
position:relative;
float:right;
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
.ol-popup {
position: absolute;
background-color: white;
box-shadow: 0 1px 4px rgba(0,0,0,0.2);
padding: 15px;
border-radius: 10px;
border: 1px solid #cccccc;
bottom: 12px;
left: -50px;
min-width: 280px;
}
.ol-popup:after, .ol-popup:before {
top: 100%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
}
.ol-popup:after {
border-top-color: white;
border-width: 10px;
left: 48px;
margin-left: -10px;
}
.ol-popup:before {
border-top-color: #cccccc;
border-width: 11px;
left: 48px;
margin-left: -11px;
}
.ol-popup-closer {
text-decoration: none;
position: absolute;
top: 2px;
right: 8px;
}
.ol-popup-closer:after {
content: "✖";
}
import {Vue, Ref, Component, Watch } from 'vue-property-decorator';
import View from 'ol/View';
import Map from 'ol/Map';
import TileLayer from 'ol/layer/Tile';
import { fromLonLat} from 'ol/proj';
import 'ol/ol.css';
import StationLayer from './StationLayer';
import MapProperties from './MapProperties';
import StationChartPopup from './StationChartPopup.vue';
import XYZ from 'ol/source/XYZ';
import AvgLayer from './AvgLayer';
export default class WeatherMap extends Vue{
@Ref('weathermap') readonly targetElement!: HTMLElement;
private map!: Map;
private projection: string = 'EPSG:3857'; //4236
private mapProperties: MapProperties = new MapProperties(null, "");
private avgLayer1: AvgLayer;
private avgLayer2: AvgLayer;
@Ref('StationChartPopup') stationChartPopup: StationChartPopup;
@Ref('popup') container: HTMLElement;
@Ref('popup-content') content: HTMLElement;
@Ref('popup-closer') closer: HTMLElement;
private overlay:Overlay;
this.overlay = new Overlay({
element: this.container,
autoPan: true,
autoPanAnimation: {
duration: 250,
},
});
/* var baseLayer: TileLayer = new TileLayer({
source: new XYZ({
attributions:
'Tiles © <a href="https://services.arcgisonline.com/ArcGIS/' +
'rest/services/World_Topo_Map/MapServer">ArcGIS</a>',
url:
'https://server.arcgisonline.com/ArcGIS/rest/services/' +
'World_Topo_Map/MapServer/tile/{z}/{y}/{x}'
})
}); */
this.map = new Map({
target: this.targetElement,
layers: [
new TileLayer({
source: new XYZ({
attributions:
'Tiles © <a href="https://services.arcgisonline.com/ArcGIS/' +
'rest/services/World_Topo_Map/MapServer">ArcGIS</a>',
url:
'https://server.arcgisonline.com/ArcGIS/rest/services/' +
'World_Topo_Map/MapServer/tile/{z}/{y}/{x}'
})
constrainResolution: true,
projection: this.projection
});
this.mapProperties = new MapProperties(this.map, this.projection);
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
this.map.on('click', (evt) => {
const coordinate = evt.coordinate;
var openPopup: boolean = false;
this.map.forEachFeatureAtPixel(evt.pixel, (feature, layer)=> {
if(layer.getClassName()===StationLayer.layerName){
this.stationChartPopup.renderGraph(this.stationLayer.getTemperatureSeriesFromFeature(feature));
openPopup = true;
this.content.innerHTML = '<p>Station: ' + feature.get("id") + '</p>';
}else{
}
});
if(openPopup){
this.overlay.setPosition(coordinate);
}else{
this.closePopUp();
}
});
this.closer.onclick = () => {
this.closePopUp();
};
}
private closePopUp():void{
this.overlay.setPosition(undefined);
this.closer.blur();
/* this.stationLayer = new StationLayer(this.mapProperties);
this.map.addLayer(this.stationLayer.getLayer()); */
}
private appendAVGLayer():void{
this.avgLayer1 = new AvgLayer(this.mapProperties);
this.map.addLayer(this.avgLayer1.getLayer());
protected layerVisibility(isVisible: boolean, layer:string):void{
//this.stationLayer.getLayer().setVisible(this.visibleLayers.has(StationLayer.layerName));
if(layer=='stationLayer'){
this.stationLayer.getLayer().setVisible(isVisible);
}else if(layer=="avgLayer1"){
}else if(layer=="avgLayer2"){
protected calculateAnomalie():void{
console.log("CALCULATE: "+this.mapProperties.completeDaterange);
console.log("AnomalieRange1: "+this.mapProperties.anomalieRange1);
console.log("AnomalieRange2: "+this.mapProperties.anomalieRange2);