Skip to content

Commit 1c1c2d8

Browse files
committed
animation path is added
1 parent 51e8503 commit 1c1c2d8

File tree

5 files changed

+114
-11
lines changed

5 files changed

+114
-11
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue3-openlayers",
3-
"version": "0.1.41",
3+
"version": "0.1.42",
44
"description": "Openlayers Wrapper for Vue3",
55
"repository": {
66
"type": "git",

src/App.vue

Lines changed: 58 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<ol-source-osm />
1212
</ol-tile-layer>
1313

14-
<ol-tile-layer ref="jawgLayer" title ="JAWG">
14+
<ol-tile-layer ref="jawgLayer" title="JAWG">
1515
<ol-source-xyz crossOrigin='anonymous' url="https://c.tile.jawg.io/jawg-dark/{z}/{x}/{y}.png?access-token=87PWIbRaZAGNmYDjlYsLkeTVJpQeCfl2Y61mcHopxXqSdxXExoTLEv7dwqBwSWuJ" />
1616
</ol-tile-layer>
1717

@@ -59,7 +59,7 @@
5959
</ol-interaction-select>
6060

6161
<ol-vector-layer title="AIRPORTS" preview="https://raw.githubusercontent.com/MelihAltintas/vue3-openlayers/main/src/assets/tr.png">
62-
<ol-source-vector ref="cities" url="https://raw.githubusercontent.com/alpers/Turkey-Maps-GeoJSON/master/tr-cities-airports.json" :format="geoJson" :projection="projection" >
62+
<ol-source-vector ref="cities" url="https://raw.githubusercontent.com/alpers/Turkey-Maps-GeoJSON/master/tr-cities-airports.json" :format="geoJson" :projection="projection">
6363

6464
<ol-interaction-modify v-if="drawEnable" @modifyend="modifyend" @modifystart="modifystart">
6565

@@ -102,7 +102,7 @@
102102
<ol-animated-clusterlayer :animationDuration="500" :distance="40" title="CLUSTER" preview="https://raw.githubusercontent.com/MelihAltintas/vue3-openlayers/main/src/assets/cluster.png">
103103

104104
<ol-source-vector ref="vectorsource">
105-
<ol-feature v-for="index in 500" :key="index" >
105+
<ol-feature v-for="index in 500" :key="index">
106106
<ol-geom-point :coordinates="[getRandomInRange(24,45,3),getRandomInRange(35,41,3)]"></ol-geom-point>
107107

108108
</ol-feature>
@@ -132,8 +132,32 @@
132132
</template>
133133
</ol-overlay>
134134

135-
</ol-map>
135+
<ol-vector-layer>
136+
<ol-source-vector>
137+
<ol-feature ref="animationPath">
138+
<ol-geom-line-string :coordinates="path"></ol-geom-line-string>
139+
<ol-style>
140+
<ol-style-stroke color="red" width="7"></ol-style-stroke>
141+
</ol-style>
142+
</ol-feature>
143+
<ol-animation-path v-if="animationPath" :path="animationPath.feature" :duration="4000" :repeat="10">
144+
145+
<ol-feature>
146+
<ol-geom-point :coordinates="path[0]"></ol-geom-point>
147+
<ol-style>
148+
<ol-style-circle :radius="10">
149+
<ol-style-fill color="blue"></ol-style-fill>
150+
<ol-style-stroke color="blue" :width="2"></ol-style-stroke>
151+
</ol-style-circle>
152+
</ol-style>
136153

154+
</ol-feature>
155+
</ol-animation-path>
156+
</ol-source-vector>
157+
158+
</ol-vector-layer>
159+
160+
</ol-map>
137161
</template>
138162

139163
<script>
@@ -175,7 +199,6 @@ export default {
175199
const drawEnable = ref(false)
176200
const drawType = ref("Point")
177201
178-
179202
const changeDrawType = (active, draw) => {
180203
drawEnable.value = active
181204
drawType.value = draw
@@ -268,12 +291,37 @@ export default {
268291
const jawgLayer = ref(null)
269292
const osmLayer = ref(null)
270293
const layerList = ref([])
294+
const path = ref([
295+
[
296+
25.6064453125,
297+
44.73302734375001
298+
],
299+
[
300+
27.759765625,
301+
44.75500000000001
302+
],
303+
[
304+
28.287109375,
305+
43.32677734375001
306+
],
307+
[
308+
30.55029296875,
309+
46.40294921875001
310+
],
311+
[
312+
31.69287109375,
313+
43.04113281250001
314+
]
315+
316+
])
317+
const animationPath = ref(null);
318+
271319
onMounted(() => {
272320
273321
layerList.value.push(jawgLayer.value.tileLayer);
274322
layerList.value.push(osmLayer.value.tileLayer);
275323
console.log(layerList.value)
276-
324+
console.log(animationPath.value)
277325
});
278326
279327
return {
@@ -305,18 +353,19 @@ export default {
305353
osmLayer,
306354
starIcon,
307355
changeDrawType,
308-
356+
path,
357+
animationPath
309358
}
310359
},
311360
}
312361
</script>
313-
<style>
314362

363+
<style>
315364
.overlay-content {
316365
background: red !important;
317366
color: white;
318367
box-shadow: 0 5px 10px rgb(2 2 2 / 20%);
319368
padding: 10px 20px;
320369
font-size: 16px;
321370
}
322-
</style>
371+
</style>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<template lang="">
2+
<slot></slot>
3+
</template>
4+
5+
<script>
6+
import FeatureAnimation from './FeatureAnimation';
7+
import Path from 'ol-ext/featureanimation/Path';
8+
import useAnimation from "@/composables/useAnimation";
9+
export default {
10+
name: 'ol-animation-path',
11+
extends: FeatureAnimation,
12+
13+
setup(props) {
14+
const {
15+
map,
16+
vectorLayer,
17+
properties
18+
} = useAnimation(Path, props);
19+
20+
return {
21+
map,
22+
vectorLayer,
23+
properties
24+
}
25+
26+
},
27+
props: {
28+
rotate: {
29+
type: Boolean,
30+
default: false
31+
},
32+
speed: {
33+
type: Number,
34+
default: 0
35+
},
36+
path: {
37+
type: Object,
38+
},
39+
}
40+
}
41+
</script>
42+
43+
<style lang="">
44+
45+
</style>

src/components/animations/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import ZoomAnimation from './ZoomAnimation.vue'
66
import TeleportAnimation from './TeleportAnimation.vue'
77
import FadeAnimation from './FadeAnimation.vue'
88
import SlideAnimation from './SlideAnimation.vue'
9+
import PathAnimation from './PathAnimation.vue'
910
function install (app) {
1011

1112
if (install.installed) {
@@ -21,6 +22,7 @@ function install (app) {
2122
app.component(TeleportAnimation.name, TeleportAnimation)
2223
app.component(FadeAnimation.name, FadeAnimation)
2324
app.component(SlideAnimation.name, SlideAnimation)
25+
app.component(PathAnimation.name, PathAnimation)
2426
}
2527

2628
export default install
@@ -32,5 +34,8 @@ function install (app) {
3234
ShakeAnimation,
3335
ZoomAnimation,
3436
TeleportAnimation,
35-
FadeAnimation
37+
FadeAnimation,
38+
PathAnimation,
39+
SlideAnimation
40+
3641
}

src/components/map/Feature.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ export default {
6464
provide('feature', feature)
6565
6666
provide('stylable', feature)
67+
68+
return{
69+
feature
70+
}
6771
},
6872
props: {
6973
properties: {

0 commit comments

Comments
 (0)