-
Notifications
You must be signed in to change notification settings - Fork 0
/
ol-style.js
111 lines (106 loc) · 3.01 KB
/
ol-style.js
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
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
var styleFunction = function(feature, resolution) {
var featureStyleFunction = feature.getStyleFunction();
var featureProperties = feature.getProperties();
if (featureStyleFunction) {
return featureStyleFunction.call(feature, resolution);
} else {
if (("fill" in featureProperties) && ("stroke" in featureProperties)) {
return new ol.style.Style({
fill: new ol.style.Fill({
color: featureProperties['fill']
}),
stroke: new ol.style.Stroke({
color: featureProperties['stroke'],
width: featureProperties['stroke-width']
})
});
} else if ("fill" in featureProperties) {
return new ol.style.Style({
fill: new ol.style.Fill({
color: featureProperties['fill']
}),
});
} else if ("stroke" in featureProperties) {
return new ol.style.Style({
stroke: new ol.style.Stroke({
color: featureProperties['stroke'],
width: featureProperties['stroke-width']
})
})
} else {
switch (feature.getGeometry().getType()) {
case 'Point': return new ol.style.Style({
image: new ol.style.RegularShape({
fill: new ol.style.Fill({
color: 'rgba(0,0,0,1)'
}),
stroke: new ol.style.Stroke({
color: '#000000',
width: 1
}),
points: 3,
radius: 15,
rotation: Math.PI / 4,
angle: 60
}),
text: new ol.style.Text({
text: featureProperties['tags']['name'],
scale: 1,
offsetY: 10,
fill: new ol.style.Fill({
color: '#FFFFFF'
}),
})
});
break;
case 'LineString': return new ol.style.Style({
stroke: new ol.style.Stroke({
color: '#f00',
width: 3
})
});
break;
case 'Polygon': return new ol.style.Style({
fill: new ol.style.Fill({
color: 'rgba(0,255,255,0.5)'
}),
stroke: new ol.style.Stroke({
color: '#000',
width: 5
})
});
break;
case 'MultiPoint': return new ol.style.Style({
image: new ol.style.Circle({
fill: new ol.style.Fill({
color: 'rgba(255,0,255,0.5)'
}),
radius: 5,
stroke: new ol.style.Stroke({
color: '#f0f',
width: 1
})
})
});
break;
case 'MultiLineString': return new ol.style.Style({
stroke: new ol.style.Stroke({
color: '#0f0',
width: 3
})
});
break;
case 'MultiPolygon': return new ol.style.Style({
fill: new ol.style.Fill({
color: 'rgba(0,0,255,0.5)'
}),
stroke: new ol.style.Stroke({
color: '#00f',
width: 1
})
});
break;
}
}
}
};