forked from xkjyeah/vue-google-maps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
basic-map-functions.html
91 lines (79 loc) · 1.98 KB
/
basic-map-functions.html
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<body>
<div id="root">
<button @click="panTo">
Pan To
</button>
<button @click="panToBounds">
Pan To Bounds
</button>
<button @click="fitBounds">
Fit Bounds
</button>
<gmap-map :center="center" :zoom="7" ref="mmm" style="width: 100%; height: 500px">
<gmap-marker :key="index" v-for="(m, index) in markers" :position="m.position" :clickable="true" :draggable="true" @click="center=m.position"></gmap-marker>
</gmap-map>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.0/vue.js"></script>
<script src="vue-google-maps.js"></script>
<script>
Vue.use(VueGoogleMaps, {
load: {
key: 'AIzaSyDf43lPdwlF98RCBsJOFNKOkoEjkwxb5Sc'
},
});
document.addEventListener('DOMContentLoaded', function() {
new Vue({
el: '#root',
data: {
center: {
lat: 10.0,
lng: 10.0
},
markers: [{
position: {
lat: 10.0,
lng: 10.0
}
}, {
position: {
lat: 11.0,
lng: 11.0
}
}]
},
methods: {
fitBounds() {
var b = new google.maps.LatLngBounds();
b.extend({
lat: 33.972,
lng: 35.4054
});
b.extend({
lat: 33.7606,
lng: 35.64592
});
this.$refs.mmm.fitBounds(b);
},
panToBounds() {
var b = new google.maps.LatLngBounds();
b.extend({
lat: 33.972,
lng: 35.4054
});
b.extend({
lat: 33.7606,
lng: 35.64592
});
this.$refs.mmm.panToBounds(b);
},
panTo() {
this.$refs.mmm.panTo({
lat: 47.912867,
lng: 106.910723
});
},
}
});
});
</script>
</body>