Skip to content

Commit 84232e9

Browse files
committed
refactor(ol-style-icon): pass-through properties from OpenLayers
BREAKING CHANGE: properties are passed-through from OpenLayers directly and property `imgSize` has been removed since it's [removed from OpenLayers 8](https://github.com/openlayers/openlayers/blob/v8.0.0/changelog/upgrade-notes.md#removal-of-olstyleicons-imgsize-property)
1 parent ff9e373 commit 84232e9

File tree

2 files changed

+19
-111
lines changed

2 files changed

+19
-111
lines changed

Diff for: docs/componentsguide/styles/icon/index.md

+7-76
Original file line numberDiff line numberDiff line change
@@ -20,82 +20,13 @@ import IconDemo from "@demos/IconDemo.vue"
2020

2121
:::
2222

23-
## Properties
23+
### Props from OpenLayers
2424

25-
### anchor
25+
Properties are passed-trough from OpenLayers directly.
26+
Their types and default values can be checked-out [in the official OpenLayers docs](https://openlayers.org/en/latest/apidoc/module-ol_style_Icon-Icon.html).
27+
Only some properties deviate caused by reserved keywords from Vue / HTML.
28+
This deviating props are described in the section below.
2629

27-
- **Type**: `Array`
30+
### Deviating Properties
2831

29-
### anchorOrigin
30-
31-
- **Type**: `String`
32-
- **Default**: `top-left`
33-
34-
### anchorXUnits
35-
36-
- **Type**: `String`
37-
- **Default**: `fraction`
38-
39-
### anchorYUnits
40-
41-
- **Type**: `String`
42-
- **Default**: `fraction`
43-
44-
### color
45-
46-
- **Type**: `String`
47-
48-
### crossOrigin
49-
50-
- **Type**: `String`
51-
52-
### img
53-
54-
- **Type**: `[HTMLImageElement, HTMLCanvasElement]`
55-
56-
### offset
57-
58-
- **Type**: `Array`
59-
- **Default**: `() => [0, 0]`
60-
61-
### displacement
62-
63-
- **Type**: `Array`
64-
- **Default**: `() => [0, 0]`
65-
66-
### offsetOrigin
67-
68-
- **Type**: `String`
69-
- **Default**: `top-left`
70-
71-
### opacity
72-
73-
- **Type**: `Number`
74-
- **Default**: `1`
75-
76-
### scale
77-
78-
- **Type**: `Number`
79-
- **Default**: `1`
80-
81-
### rotateWithView
82-
83-
- **Type**: `Boolean`
84-
- **Default**: `false`
85-
86-
### rotation
87-
88-
- **Type**: `Number`
89-
- **Default**: `0`
90-
91-
### size
92-
93-
- **Type**: `Array`
94-
95-
### imgSize
96-
97-
- **Type**: `Array`
98-
99-
### src
100-
101-
- **Type**: `String`
32+
None.

Diff for: src/components/styles/OlStyleIcon.vue

+12-35
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,25 @@
22
<div v-if="false"></div>
33
</template>
44
<script setup lang="ts">
5-
import type { IconAnchorUnits, IconOrigin } from "ol/style/Icon";
6-
import Icon from "ol/style/Icon";
7-
5+
import Icon, { type Options } from "ol/style/Icon";
86
import type { Ref } from "vue";
97
import { inject, watch, onMounted, onUnmounted, computed } from "vue";
108
import type Style from "ol/style/Style";
119
import type Draw from "ol/interaction/Draw";
1210
import type Modify from "ol/interaction/Modify";
13-
import type { Size } from "ol/size";
1411
import usePropsAsObjectProperties from "@/composables/usePropsAsObjectProperties";
1512
16-
const props = withDefaults(
17-
defineProps<{
18-
anchor?: number[];
19-
anchorOrigin?: IconOrigin;
20-
anchorXUnits?: IconAnchorUnits;
21-
color?: string;
22-
crossOrigin?: string;
23-
img?: HTMLImageElement | HTMLCanvasElement;
24-
offset?: [number, number];
25-
displacement?: [number, number];
26-
offsetOrigin?: IconOrigin;
27-
opacity?: number;
28-
scale?: number;
29-
rotateWithView?: boolean;
30-
rotation?: number;
31-
size?: Size;
32-
imgSize?: Size;
33-
src?: string;
34-
}>(),
35-
{
36-
anchorOrigin: "top-left",
37-
anchorXUnits: "fraction",
38-
offset: () => [0, 0],
39-
displacement: () => [0, 0],
40-
offsetOrigin: "top-left",
41-
opacity: 1,
42-
scale: 1,
43-
rotateWithView: false,
44-
rotation: 0,
45-
}
46-
);
13+
const props = withDefaults(defineProps<Options>(), {
14+
anchorOrigin: "top-left",
15+
anchorXUnits: "fraction",
16+
offset: () => [0, 0],
17+
displacement: () => [0, 0],
18+
offsetOrigin: "top-left",
19+
opacity: 1,
20+
scale: 1,
21+
rotateWithView: false,
22+
rotation: 0,
23+
});
4724
4825
const style = inject<Ref<Style | null> | null>("style", null);
4926
const styledObj = inject<Ref<Draw | Modify | Style | null> | null>(

0 commit comments

Comments
 (0)