Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import VectorLayer from 'ol/layer/Vector';
import VectorSource from 'ol/source/Vector';
import GeoJSON from 'ol/format/GeoJSON';
import {Circle as CircleStyle, Fill, Stroke, Style, Text} from 'ol/style';
import MapProperties from './MapProperties';
export default class StationLayer{
private layer: any;
private mapProperties: MapProperties;
constructor(mapProperties: MapProperties){
this.mapProperties = mapProperties;
this.layer = new VectorLayer({
source: new VectorSource({
url: "http://localhost/germanStation.geojson",
format: new GeoJSON(),
}),
style: (feature)=>{return this.stationStyle(feature)}
})
}
public getLayer(): any{
return this.layer;
}
protected stationStyle(feature){
console.log(feature.getProperties());
let fontSize = 15
let label = '\u272A';
if(this.mapProperties.getZoomLevel()>=8){
label += "\n"+feature.get("id");
}
return new Style({
text: new Text({
font: fontSize+'px Helvetica,bold',
overflow: true,
fill: new Fill({
color: 'rgba(0,0,0,1)'
}),
offsetY: 0,
text: label
})
});
}
}