Skip to Content
vue2-google-maps

vue2-google-maps

Introduction

google map을 vue2에서 사용할 수 있게 해주는 라이브러리

GroundOverlay Custom Component 구조 설명

Gmap 관련

check current Google map version

async mounted() { this.$refs.mapRef.$mapPromise.then((map) => { console.log(google.maps.version) // ⇐ }) }

Marker Animation

https://developers.google.com/maps/documentation/javascript/markers?hl=ko#animate

  • 마커에 애니메이션 적용
  • 다양한 상황에서 동적인 움직임을 보이도록 마커에 애니메이션을 적용할 수 있습니다. 마커에 애니메이션이 적용되는 방식을 지정하려면 마커의 animation 속성(google.maps.Animation 유형)을 사용하세요. 다음과 같은 Animation 값이 지원됩니다.
  • DROP은 마커를 처음 지도에 배치할 때 지도 상단에서 최종 위치로 떨어져야 함을 나타냅니다. 마커가 멈추면 애니메이션이 중지되고 animation이 null로 돌아갑니다. 이 유형의 애니메이션은 일반적으로 Marker를 생성하는 동안 지정됩니다.
  • BOUNCE는 마커가 제자리에서 튀어야 함을 나타냅니다. 튀는 마커는 animation 속성이 명시적으로 null이 될 때까지 계속 튑니다.
  • 기존 마커의 경우 Marker 객체에서 setAnimation()을 호출하여 애니메이션을 시작할 수 있습니다.

InfoWindow

https://developers.google.com/maps/documentation/javascript/reference/info-window#InfoWindowOptions

GmapCircle

https://developers.google.com/maps/documentation/javascript/reference/polygon?hl=ko#Circle

interval을 활용한 GmapCircle 점멸 효과

<template> <GmapCircle :center="center" :radius="200" :visible="true" :options="circleOption" /> </template> <script> export default { data() { return { blinkInterval: null, circleOption: { strokeColor: '#888888', strokeOpacity: 0.8, strokeWeight: 2, fillColor: '#888888', fillOpacity: 1, clickable: true, }, } }, mounted() { // opacity를 활용한 점멸 효과 this.blinkInterval = setInterval(() => { if (this.circleOption.fillOpacity > 0.1) { this.circleOption.fillOpacity -= 0.1 } else { this.circleOption.fillOpacity = 1 } }, 500); // 0.5초 간격 }, beforeDestroy() { if (this.blinkInterval) { clearInterval(this.blinkInterval); } }, } </script>
Last updated on