-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathexample.vue
70 lines (66 loc) · 1.86 KB
/
example.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<template>
<v-map :zoom=10 :center="initialLocation">
<v-tilelayer url="http://{s}.tile.osm.org/{z}/{x}/{y}.png"></v-tilelayer>
<v-polyline-decorator :paths="[latlngs]" :patterns="patterns"></v-polyline-decorator>
<v-polyline :opacity="0.5" :latLngs="latlngs"></v-polyline>
</v-map>
</template>
<script>
import L from 'leaflet'
import * as Vue2Leaflet from 'vue2-leaflet'
import Vue2LeafletPolylinedecorator from './Vue2LeafletPolylinedecorator'
function rand() {
let max = 0
let min = 0.1
return Math.random() * (max - min) + min;
}
export default {
components: {
'v-map': Vue2Leaflet.LMap,
'v-tilelayer': Vue2Leaflet.LTileLayer,
'v-polyline': Vue2Leaflet.LPolyline,
'v-polyline-decorator': Vue2LeafletPolylinedecorator
},
methods: {
},
data () {
let x = -35.15;
let y = -58.2;
let latlngs = []
for (let i = 0; i < 10; i++) {
latlngs.push(L.latLng(x, y))
x += rand();
y += rand();
}
let patterns = [
{ offset: 12, repeat: 25, symbol: L.Symbol.dash({pixelSize: 10, pathOptions: {color: '#f00', weight: 2}}) },
{ offset: 0, repeat: 25, symbol: L.Symbol.dash({pixelSize: 0}) }
]
setTimeout(function mutateLatLngs() {
latlngs.length = 0;
let x = -35.15;
let y = -58.2;
for (let i = 0; i < 10; i++) {
latlngs.push(L.latLng(x, y))
x += rand();
y += rand();
}
patterns.push({ offset: 6, repeat: 25, symbol: L.Symbol.dash({pixelSize: 5, pathOptions: {color: '#000', weight: 5}}) })
}, 3000);
return {
patterns,
latlngs,
initialLocation: L.latLng(x-0.3, y-0.3)
}
},
mounted() {
}
}
</script>
<style>
@import "~leaflet/dist/leaflet.css";
html, body {
height: 100%;
margin: 0;
}
</style>