Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

documented way to catch events doesn't work #100

Open
sdetweil opened this issue Jun 7, 2024 · 1 comment
Open

documented way to catch events doesn't work #100

sdetweil opened this issue Jun 7, 2024 · 1 comment

Comments

@sdetweil
Copy link

sdetweil commented Jun 7, 2024

the example here on how to 'watch' the ref on the map object doesn't produce any events

https://vue-google-maps-community-fork.netlify.app/examples/how-to-access-google-maps-object.html#how-to-access-google-maps-object

@sdetweil
Copy link
Author

sdetweil commented Jun 7, 2024

this is the way that does work , 'myMapRef' matches the ref= on the GMapMap tag

 <GMapMap  ref="myMapRef" :center="currentMapCenter" :zoom="zoomLevel" map-type-id="terrain" :options="mapOptions"

(I save the returned listener handle to an array (this.listeners) for cleanup on exit)

mounted(){
        this.map = await this.$refs.myMapRef.$mapPromise;
  
        this.listeners.push(this.map.addListener("center_changed", () => {
            // 3 seconds after the center of the map has changed, pan back to the
            // marker.
            console.log("new center ="+JSON.stringify(this.map.getCenter()))
        }));
        this.listeners.push(this.map.addListener("bounds_changed", () => {
            // 3 seconds after the center of the map has changed, pan back to the
            // marker.
            console.log("new bounds =" + JSON.stringify(this.map.getBounds()))
        }));
        this.listeners.push(this.map.addListener("zoom_changed", () => {
            // 3 seconds after the center of the map has changed, pan back to the
            // marker.
            console.log("new zoom =" + JSON.stringify(this.map.getZoom()))
        }));
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant