I am using the vue2-google-maps api with and I want to have a button that will change where the map is centered on. What code do I need to include to get the map re-centered.
I've tried different functions such as map_center and mapCenter, but I just can't find the right one to use, even after many web searches.
<div>
<button @click="setCenter">Re-center</button>
<br/>
</div>
<gmap-map
:center="{ lat: 41.693206, lng: -86.228631 }"
:zoom="12"
style="width:100%; height: 65vh;"
:options="{
zoomControl: true,
mapTypeControl: false,
scaleControl: false,
streetViewControl: false,
rotateControl: false,
fullscreenControl: false,
disableDefaultUi: false
}"
>
</gmap-map>
<script>
export default {
name: 'Home',
methods: {
setCenter () {
this.map_center = {lat: '41.9028', lng: '12.4964'}
}
}
}
</script>
In main.js:
import * as VueGoogleMaps from 'vue2-google-maps'
Vue.use(VueGoogleMaps, {
load: {
key: 'AIzaSyBNGgSXjtrJCMkZaqoxo2KGDe-DdJUVMa0',
libraries: 'places'
}
})
I expected that when the button is clicked, the map would move from South Bend, IN to Rome, Italy. However, nothing happens when the button is clicked.