Skip to content

Commit 9c46e0d

Browse files
committed
refactor(ol-geom-line-string): migrate to script setup
1 parent 78776c7 commit 9c46e0d

File tree

4 files changed

+37
-55
lines changed

4 files changed

+37
-55
lines changed

docs/componentsguide/geometries/geomlinestring/index.md

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import LineString from "@demos/LineString.vue"
1616
<ol-map
1717
:loadTilesWhileAnimating="true"
1818
:loadTilesWhileInteracting="true"
19-
style="height:400px"
19+
style="height: 400px"
2020
>
2121
<ol-view
2222
ref="view"
@@ -65,29 +65,15 @@ import LineString from "@demos/LineString.vue"
6565
</ol-map>
6666
</template>
6767
68-
<script>
68+
<script setup>
6969
import { ref } from "vue";
70-
export default {
71-
setup() {
72-
const center = ref([116.54875, 40.45064]);
73-
const projection = ref("EPSG:4326");
74-
const zoom = ref(17);
75-
const rotation = ref(0);
76-
const radius = ref(40);
77-
const strokeWidth = ref(10);
78-
const strokeColor = ref("red");
7970
80-
return {
81-
center,
82-
projection,
83-
zoom,
84-
rotation,
85-
radius,
86-
strokeWidth,
87-
strokeColor,
88-
};
89-
},
90-
};
71+
const center = ref([116.54875, 40.45064]);
72+
const projection = ref("EPSG:4326");
73+
const zoom = ref(17);
74+
const rotation = ref(0);
75+
const strokeWidth = ref(10);
76+
const strokeColor = ref("red");
9177
</script>
9278
```
9379

src/components/geometries/LineString.vue

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<template lang="">
2+
<div v-if="false"></div>
3+
</template>
4+
5+
<script setup>
6+
import LineString from "ol/geom/LineString";
7+
import useGeometry from "@/composables/useGeometry";
8+
9+
const props = defineProps({
10+
coordinates: {
11+
type: Array,
12+
},
13+
opt_layout: {
14+
type: String,
15+
default: "XY",
16+
},
17+
});
18+
19+
const { geometry } = useGeometry(LineString, props);
20+
21+
defineExpose({
22+
geometry,
23+
});
24+
</script>
25+
26+
<style lang=""></style>

src/components/geometries/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import OlGeomCircle from "./OlGeomCircle.vue";
2+
import OlGeomLineString from "./OlGeomLineString.vue";
23
import Point from "./Point.vue";
3-
import LineString from "./LineString.vue";
44
import Polygon from "./Polygon.vue";
55
import MultiPoint from "./MultiPoint.vue";
66
import MultiLineString from "./MultiLineString.vue";
@@ -14,8 +14,8 @@ function install(app) {
1414
install.installed = true;
1515

1616
app.component("ol-geom-circle", OlGeomCircle);
17+
app.component("ol-geom-line-string", OlGeomLineString);
1718
app.component(Point.name, Point);
18-
app.component(LineString.name, LineString);
1919
app.component(Polygon.name, Polygon);
2020
app.component(MultiPoint.name, MultiPoint);
2121
app.component(MultiLineString.name, MultiLineString);
@@ -27,8 +27,8 @@ export default install;
2727
export {
2828
install,
2929
OlGeomCircle,
30+
OlGeomLineString,
3031
Point,
31-
LineString,
3232
Polygon,
3333
MultiPoint,
3434
MultiLineString,

0 commit comments

Comments
 (0)