0
私は現在、コンポーネントがマウントされているときにlatとlngが選択されていないため、Googleマップを反応させる方法を考えています。私のコードを見てみましょう:このコンポーネントはGoogleマップを有効にするにはどうすればよいですか?
<template>
<div>
<div class="google-map" id="sidebar-map"></div>
</div>
</template>
<script>
export default {
props: ["coordinates", "zoom"],
data() {
return {
latLng: {
lat: 0,
lng: 0
}
}
},
mounted() {
this.latLng = this.coordinates;
let map = new google.maps.Map(document.getElementById('sidebar-map'), {
zoom: this.zoom,
center: this.latLng
});
let marker = new google.maps.Marker({
position: this.latLng,
map: map
});
}
}
</script>
私は、データがnew google.maps.Map
とnew google.maps.Marker
変更されることができます任意の方法はありますか?
どのようなアイデアや方向性/ヒントも高く評価されます。
私はその解決策についてどう考えなかったかわかりません。どうもありがとう! – Chris