xkjyeah / vue-google-maps

Google maps component for vue with 2-way data binding
https://xkjyeah.github.io/vue-google-maps/
1.88k stars 474 forks source link

There doesn't seem to be anyway to add an event listener to the map that allows marker placement based on a user's click event #787

Closed GraplnMonkey closed 2 years ago

GraplnMonkey commented 2 years ago

I might be using this wrong, but most of the point of using Google Maps is the ability to capture user interactions and transfer that event object to functions that use features like Markers. If this doesn't work this package is pretty useless...

zeke8402 commented 2 years ago

Can you be more specific with what you're trying to do? The GmapMap component emits events already, so you can do <GmapMap @click=mapAction>, mapAction will receive lat/lng data relative to where the user clicked on the map.

GraplnMonkey commented 2 years ago

We're good. What I needed to do was add an event listener to the map for clicks:

google.maps.event.addListener(this.map, "click", (e) => {        new window.google.maps.Marker({       position: {lat: e.latLng.lat(), lng: e.latLng.lng()},       map: this.map