I have created leaflet map with readily available vue component 'l-map' imported from 'vue2-leaflet. Now I want to recenter the map on button click but I do not know how to gain access to 'map' object (as shown in many examples with functions like 'map.flyTo()', etc) which is used to create map through functions. I tried adding 'center' in @watch property and assign it to 'center' attribute of l-map tag but the map didn't show any changes based on changes in it's value. How can I access map functions when I create it using component from 'vue2-leaflet library??
<template>
<l-map :zoom="zoom" :center="center">
<v-btn small @click="recenterMap()">
<span class="mdi mdi-target" />
</v-btn>
</l-map>
</template>
<script lang="ts">
import { LMap, LControl } from "vue2-leaflet";
import { Component, Vue } from 'vue-property-decorator';
@Component({
components: {
LMap,
LControl
}
})
export default class MyMap extends Vue {
center= { lat: 11.016749, lng: 76.955817 };
recenterMap(){}
}
</script>