Skip to content

Commit 320fa0d

Browse files
committed
refactor("ol-source-webglpoints): migrate to script setup
1 parent b9d385d commit 320fa0d

File tree

3 files changed

+34
-46
lines changed

3 files changed

+34
-46
lines changed

src/components/sources/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import OlSourceTianDiTu from "./OlSourceTianDiTu.vue";
77
import OlSourceTileArcGISRest from "@/components/sources/OlSourceTileArcGISRest.vue";
88
import OlSourceTileWMS from "./OlSourceTileWMS.vue";
99
import OlSourceVector from "./OlSourceVector.vue";
10+
import OlSourceWebglPoints from "./OlSourceWebglPoints.vue";
1011
import OlSourceXYZ from "./OlSourceXYZ.vue";
1112
import OlSourceWMTS from "./OlSourceWMTS.vue";
12-
import SourceWebglPoints from "./SourceWebglPoints.vue";
1313

1414
function install(app) {
1515
if (install.installed) {
@@ -27,9 +27,9 @@ function install(app) {
2727
app.component("ol-source-tile-arcgis-rest", OlSourceTileArcGISRest);
2828
app.component("ol-source-tile-wms", OlSourceTileWMS);
2929
app.component("ol-source-vector", OlSourceVector);
30+
app.component("ol-source-webglpoints", OlSourceWebglPoints);
3031
app.component("ol-source-xyz", OlSourceXYZ);
3132
app.component("ol-source-wmts", OlSourceWMTS);
32-
app.component(SourceWebglPoints.name, SourceWebglPoints);
3333
}
3434

3535
export default install;
@@ -45,7 +45,7 @@ export {
4545
OlSourceTileArcGISRest,
4646
OlSourceTileWMS,
4747
OlSourceVector,
48+
OlSourceWebglPoints,
4849
OlSourceXYZ,
4950
OlSourceWMTS,
50-
SourceWebglPoints,
5151
};

src/demos/WebglPointsLayerDemo.vue

Lines changed: 31 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -25,53 +25,41 @@
2525
</ol-map>
2626
</template>
2727

28-
<script>
28+
<script setup>
2929
import { ref, inject } from "vue";
30-
export default {
31-
setup() {
32-
const center = ref([40, 40]);
33-
const projection = ref("EPSG:4326");
34-
const zoom = ref(3);
35-
const rotation = ref(0);
3630
37-
const format = inject("ol-format");
38-
const geoJson = new format.GeoJSON();
31+
const center = ref([40, 40]);
32+
const projection = ref("EPSG:4326");
33+
const zoom = ref(3);
34+
const rotation = ref(0);
3935
40-
const webglPointsStyle = {
41-
symbol: {
42-
symbolType: "circle",
43-
size: [
44-
"interpolate",
45-
["linear"],
46-
["get", "population"],
47-
40000,
48-
8,
49-
2000000,
50-
28,
51-
],
52-
color: "#ffed02",
53-
rotateWithView: false,
54-
offset: [0, 0],
55-
opacity: [
56-
"interpolate",
57-
["linear"],
58-
["get", "population"],
59-
40000,
60-
0.6,
61-
2000000,
62-
0.92,
63-
],
64-
},
65-
};
36+
const format = inject("ol-format");
37+
const geoJson = new format.GeoJSON();
6638
67-
return {
68-
center,
69-
projection,
70-
zoom,
71-
rotation,
72-
geoJson,
73-
webglPointsStyle,
74-
};
39+
const webglPointsStyle = {
40+
symbol: {
41+
symbolType: "circle",
42+
size: [
43+
"interpolate",
44+
["linear"],
45+
["get", "population"],
46+
40000,
47+
8,
48+
2000000,
49+
28,
50+
],
51+
color: "#ffed02",
52+
rotateWithView: false,
53+
offset: [0, 0],
54+
opacity: [
55+
"interpolate",
56+
["linear"],
57+
["get", "population"],
58+
40000,
59+
0.6,
60+
2000000,
61+
0.92,
62+
],
7563
},
7664
};
7765
</script>

0 commit comments

Comments
 (0)