Skip to content

How to fit bounds automatically in order to see all the markers #49

Answered by tahaipek
Amaurgit asked this question in Q&A
Discussion options

You must be logged in to vote

Can you try this solution?

 data() {
    return {
      markers: [],
    };
  },
  methods: {

    fitBoundsOnMap() {
      this.$refs.googleMapRef.$mapPromise.then((mapObject) => {

        var bounds = new google.maps.LatLngBounds();

        this.markers.forEach((marker) => {
          bounds.extend(marker.position);
        });

        mapObject.fitBounds(bounds);
      });
    },
},

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@felixranesberger
Comment options

@felixranesberger
Comment options

Answer selected by tahaipek
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
advise or question Seeking for advise or question
3 participants