Skip to content

Commit c1d050f

Browse files
committed
feat(ol-style-text): support all ol props
closes #411
1 parent b13c120 commit c1d050f

File tree

2 files changed

+10
-104
lines changed

2 files changed

+10
-104
lines changed

docs/componentsguide/styles/text/index.md

Lines changed: 7 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -34,87 +34,13 @@ Add text to shapes
3434

3535
## Properties
3636

37-
### font
37+
### Props from OpenLayers
3838

39-
- **Type**: `String`
39+
Properties are passed-trough from OpenLayers directly.
40+
Their types and default values can be checked-out [in the official OpenLayers docs](https://openlayers.org/en/latest/apidoc/module-ol_style_Text-Text.html).
41+
Only some properties deviate caused by reserved keywords from Vue / HTML.
42+
This deviating props are described in the section below.
4043

41-
### maxAngle
44+
### Deviating Properties
4245

43-
- **Type**: `Number`
44-
- **Default**: `Math.PI / 4`
45-
46-
### offsetX
47-
48-
- **Type**: `Number`
49-
- **Default**: `0`
50-
51-
### offsetY
52-
53-
- **Type**: `Number`
54-
- **Default**: `0`
55-
56-
### overflow
57-
58-
- **Type**: `Boolean`
59-
- **Default**: `false`
60-
61-
### placement
62-
63-
- **Type**: `String`
64-
- **Default**: `point`
65-
66-
### scale
67-
68-
- **Type**: `Number`
69-
70-
### rotateWithView
71-
72-
- **Type**: `Boolean`
73-
- **Default**: `false`
74-
75-
### rotation
76-
77-
- **Type**: `Number`
78-
- **Default**: `0`
79-
80-
### text
81-
82-
- **Type**: `String`
83-
84-
### textAlign
85-
86-
- **Type**: `String`
87-
88-
### textBaseline
89-
90-
- **Type**: `String`
91-
- **Default**: `middle`
92-
93-
### padding
94-
95-
- **Type**: `Array`
96-
- **Default**: `() => [0, 0, 0, 0]`
97-
98-
### backgroundFill
99-
100-
- **Type**: `array`, `string`
101-
102-
Fill color for the text background when `placement` is 'point'. Default is no fill. Either in hexadecimal or as RGBA array with red, green, and blue values betweeen 0 and 255 and alpha value between 0 and 1 inclusive.
103-
104-
### backgroundStroke
105-
106-
- **Type**: `Object`
107-
108-
Stroke style for the text background when `placement` is 'point'. Default is no stroke. Please see [ol-style-stroke](/componentsguide/styles/stroke/#properties) for available options.
109-
110-
### fill
111-
112-
- **Type**: `array`, `string`
113-
114-
Fill color for the text. Default is '#333'. Either in hexadecimal or as RGBA array with red, green, and blue values betweeen 0 and 255 and alpha value between 0 and 1 inclusive.
115-
116-
### stroke
117-
118-
- **Type**: `Object`
119-
120-
Stroke style for the text. Default is no stroke. Please see [ol-style-stroke](/componentsguide/styles/stroke/#properties) for available options.
46+
None.

src/components/styles/OlStyleText.vue

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,18 @@
55
</template>
66

77
<script setup lang="ts">
8-
import Text, { type Options, type TextPlacement } from "ol/style/Text";
8+
import Text, { type Options } from "ol/style/Text";
99
import Fill from "ol/style/Fill";
10-
import Stroke, { type Options as StrokeOptions } from "ol/style/Stroke";
10+
import Stroke from "ol/style/Stroke";
1111
import type { Ref } from "vue";
1212
import { inject, watch, onMounted, onUnmounted, provide, computed } from "vue";
1313
import type Style from "ol/style/Style";
1414
import type Draw from "ol/interaction/Draw";
1515
import type Modify from "ol/interaction/Modify";
1616
import usePropsAsObjectProperties from "@/composables/usePropsAsObjectProperties";
17-
import type { Color } from "ol/color";
18-
import type { ColorLike } from "ol/colorlike";
1917
import { Interaction } from "ol/interaction";
2018
21-
const props = defineProps<{
22-
font?: string;
23-
maxAngle?: number;
24-
offsetX?: number;
25-
offsetY?: number;
26-
overflow?: boolean;
27-
placement?: TextPlacement;
28-
scale?: number;
29-
rotateWithView?: boolean;
30-
rotation?: number;
31-
text?: string;
32-
textAlign?: CanvasTextAlign;
33-
textBaseline?: CanvasTextBaseline;
34-
padding?: [number, number, number, number];
35-
fill?: Color | ColorLike;
36-
stroke?: StrokeOptions;
37-
backgroundFill?: Color | ColorLike;
38-
backgroundStroke?: StrokeOptions;
39-
}>();
19+
const props = defineProps<Options>();
4020
4121
const style = inject<Ref<Style | null> | null>("style", null);
4222
const styledObj = inject<Ref<Draw | Modify | Style | null> | null>(

0 commit comments

Comments
 (0)