@masterportal/masterportalapi 2.20.0 → 2.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,61 @@
1
+ import StyleClass from "./style";
2
+ import {Circle, Fill, Stroke, Style} from "ol/style.js";
3
+ import defaultStyle from "./defaultStyles";
4
+
5
+ class CircleStyle extends StyleClass {
6
+ /**
7
+ * @description Class to create ol.style.Style
8
+ * @constructor
9
+ * @class CircleStyle
10
+ * @extends StyleClass
11
+ * @memberof VectorStyle.Style
12
+ */
13
+ constructor () {
14
+ super();
15
+ this.attributes = {...defaultStyle.circle};
16
+ }
17
+
18
+ /**
19
+ * This function initializes the Linestring Object by setting or overwriting some attributes.
20
+ * @param {ol/feature} feature Feature to be styled.
21
+ * @param {object} styles styling properties to overwrite defaults
22
+ * @param {Boolean} isClustered Flag to show if feature is clustered.
23
+ * @returns {void}
24
+ */
25
+ initialize (feature, styles, isClustered) {
26
+ this.setFeature(feature);
27
+ this.setIsClustered(isClustered);
28
+ this.overwriteStyling(styles);
29
+ this.setStyle(this.createStyle());
30
+ }
31
+
32
+ /**
33
+ * This function returns a style for each feature.
34
+ * @returns {ol/style/Style} - The created style.
35
+ */
36
+ createStyle () {
37
+ if (this.nullStyle) {
38
+ return null;
39
+ }
40
+
41
+ const fill = new Fill({
42
+ color: this.attributes.circleFillColor
43
+ }),
44
+ stroke = new Stroke({
45
+ color: this.attributes.circleStrokeColor,
46
+ width: this.attributes.circleStrokeWidth
47
+ });
48
+
49
+ return new Style({
50
+ image: new Circle({
51
+ fill: fill,
52
+ stroke: stroke,
53
+ radius: 0
54
+ }),
55
+ fill: fill,
56
+ stroke: stroke
57
+ });
58
+ }
59
+ }
60
+
61
+ export default CircleStyle;