forked from GuillaumeLeclerc/vue-google-maps
-
Notifications
You must be signed in to change notification settings - Fork 475
/
basic-autocomplete.html
74 lines (66 loc) · 1.8 KB
/
basic-autocomplete.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
<body>
<div id="root">
<h1>Changing Default Place updates text box</h1>
<button @click="setDescription('Tokyo')">Set to Tokyo</button><br/>
<button @click="setDescription('Shanghai')">Set to Shanghai</button><br/>
<button @click="setDescription('Seoul')">Set to Seoul</button><br/>
<label>
Place:
<gmap-autocomplete :value="description"
placeholder="This is a placeholder text"
@place_changed="setPlace"
:select-first-on-enter="true">
</gmap-autocomplete>
</label>
<br/>
{{latLng.lat}},
{{latLng.lng}}
<div>
<h2>Options work</h2>
You cannot find the state of Texas in this
<label>
Only locations in Singapore:
<gmap-autocomplete
:value="description"
@place_changed="setPlace"
:options="{
bounds: {north: 1.4, south: 1.2, east: 104, west: 102},
strictBounds: true
}">
</gmap-autocomplete>
</label>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.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: {
description: 'Singapore',
latLng: {}
},
methods: {
setDescription(description) {
this.description = description;
},
setPlace(place) {
if (!place) return
this.latLng = {
lat: place.geometry.location.lat(),
lng: place.geometry.location.lng(),
};
}
}
});
});
</script>
</body>