forked from xkjyeah/vue-google-maps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasic-place-input.html
51 lines (45 loc) · 1.2 KB
/
basic-place-input.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
<body>
<div id="root">
<h1>Changing Default Place updates text box</h1>
<button @click="setPlaceText('Tokyo')">Set to Tokyo</button><br/>
<button @click="setPlaceText('Shanghai')">Set to Shanghai</button><br/>
<button @click="setPlaceText('Seoul')">Set to Seoul</button><br/>
<gmap-place-input :default-place="place"
@place_changed="setPlace">
</gmap-place-input>
<br/>
{{latLng.lat}},
{{latLng.lng}}
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.1.10/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',
libraries: 'places'
},
});
document.addEventListener('DOMContentLoaded', function() {
new Vue({
el: '#root',
data: {
place: 'Singapore',
latLng: {}
},
methods: {
setPlaceText(place) {
this.place = place;
},
setPlace(place) {
this.latLng = {
lat: place.geometry.location.lat(),
lng: place.geometry.location.lng(),
};
}
}
});
});
</script>
</body>