1
1
<template >
2
2
<label for =" count" >Marker:</label >
3
- <input type =" number" id =" count" v-model =" count" />
3
+ <input type =" number" id =" count" v-model.number =" count" max = " 50000 " />
4
4
<ol-map
5
5
:loadTilesWhileAnimating =" true"
6
6
:loadTilesWhileInteracting =" true"
29
29
30
30
<ol-animated-clusterlayer :animationDuration =" 500" :distance =" 40" >
31
31
<ol-source-vector
32
- ref = " vectorsource "
33
- :features = " features "
32
+ :features = " geoJsonFeatures "
33
+ :format = " geoJson "
34
34
@featuresloadstart =" featuresloadstart"
35
35
@featuresloadend =" featuresloadend"
36
36
@featuresloaderror =" featuresloaderror"
58
58
</ol-map >
59
59
</template >
60
60
61
- <script setup>
61
+ <script setup lang="ts" >
62
62
import { computed , ref } from " vue" ;
63
- import { Point } from " ol/geom" ;
64
- import Feature from " ol/Feature" ;
65
63
import markerIcon from " @/assets/marker.png" ;
66
- import { arrayWith500Points } from " ./points" ;
64
+ import { arrayWith50000Points } from " ./points" ;
65
+ import { GeoJSON } from " ol/format" ;
66
+ import type { FeatureLike } from " ol/Feature" ;
67
+ import type { SelectEvent } from " ol/interaction/Select" ;
67
68
68
69
const center = ref ([40 , 40 ]);
69
70
const projection = ref (" EPSG:4326" );
70
71
const zoom = ref (5 );
71
72
const rotation = ref (0 );
72
- const count = ref (5000 );
73
-
74
- const features = computed (() => {
75
- return Array .from ({ length: count .value }, (_ , i ) => {
76
- return new Feature ({
77
- geometry: new Point (arrayWith500Points[index - 1 ]),
78
- index: i,
79
- });
73
+ const count = ref (1000 );
74
+
75
+ const geoJson = new GeoJSON ();
76
+
77
+ const geoJsonFeatures = computed (() => {
78
+ const features = Array .from ({ length: count .value }, (_ , i ) => {
79
+ return {
80
+ type: " Feature" ,
81
+ properties: {},
82
+ geometry: {
83
+ type: " Point" ,
84
+ coordinates: arrayWith50000Points [i ],
85
+ },
86
+ };
80
87
});
88
+
89
+ const providerFeatureCollection = {
90
+ type: " FeatureCollection" ,
91
+ features ,
92
+ };
93
+
94
+ return geoJson .readFeatures (providerFeatureCollection );
81
95
});
82
96
83
- const overrideStyleFunction = (feature , style ) => {
97
+ const overrideStyleFunction = (feature : FeatureLike , style : any ) => {
84
98
const clusteredFeatures = feature .get (" features" );
85
99
const size = clusteredFeatures .length ;
86
100
@@ -106,10 +120,9 @@ const overrideStyleFunction = (feature, style) => {
106
120
return style ;
107
121
};
108
122
109
- const featureSelected = (event ) => {
123
+ const featureSelected = (event : SelectEvent ) => {
110
124
console .log (event );
111
125
};
112
-
113
126
function featuresloadstart() {
114
127
console .log (" features load start" );
115
128
}
0 commit comments