[Vuejs]-How to catch Google Map Event with listener in vue.js

2👍

You may use a global event bus in scenario like this

const EventBus = new Vue();

google.maps.event.addListenerOnce(map, "bounds_changed", function() {
  //   ...
  EventBus.$emit("bounds_changed", {
    bounds,
    northEast,
    southWest
  });
});

new Vue({
  el: "#app",
  created() {
    EventBus.$on("bounds_changed", ({ bounds, northEast, southWest }) => {
      // put your operation in vue here
    });
  }
});

Leave a comment