forked from xkjyeah/vue-google-maps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-map-center-twoway.html
96 lines (87 loc) · 2.06 KB
/
test-map-center-twoway.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
92
93
94
95
96
<head>
<meta charset="utf-8" />
<style>
.map-container {
width: 400px;
height: 400px;
display: inline-block;
}
</style>
</head>
<body>
<script>
var tests = [];
</script>
<div id="test1">
<h2>Test 1</h2>
<ol>
<li>You can pan around this map, and the center is updated.</li>
<li>When you edit the lat/lng the map center is updated</li>
</ol>
<div>
Lat: <input type="number"
v-model.number.lazy="reportedMapCenter.lat"
@change="sync"
step="0.00001" />
</div>
<div>
Lng: <input type="number"
v-model.number.lazy="reportedMapCenter.lng"
@change="sync"
step="0.00001" />
</div>
<gmap-map :center="mapCenter" :zoom="12"
ref="map"
@center_changed="updateCenter"
@idle="sync"
class="map-container">
</gmap-map>
<gmap-street-view-panorama
:position="mapCenter"
ref="pano"
@position_changed="updateCenter"
:pov="pov"
class="map-container">
</gmap-street-view-panorama>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.0/vue.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.16.4/lodash.js"></script>
<script src="vue-google-maps.js"></script>
<script>
Vue.use(VueGoogleMaps, {
load: {
key: 'AIzaSyDf43lPdwlF98RCBsJOFNKOkoEjkwxb5Sc',
}
});
document.addEventListener('DOMContentLoaded', function() {
new Vue({
el: '#test1',
data: {
reportedMapCenter: {
lat: 1.32,
lng: 103.8
},
mapCenter: null,
pov: {
pitch: 0,
heading: 0,
},
},
created () {
this.sync()
},
methods: {
updateCenter(latLng) {
this.reportedMapCenter = {
lat: latLng.lat(),
lng: latLng.lng(),
}
},
sync () {
this.mapCenter = this.reportedMapCenter
}
}
});
});
</script>
</body>