Hi guys I have such a problem Can't get click coordinates to generate a new Marker
enter image description here enter image description here
CodePudding user response:
The click handler should be @click="save"
, not @:click="save"
CodePudding user response:
If you want to get the click coordinates, you should declare your save function like so:
function save(event) {
console.log(event.clientX, event.clientY)
}
And if you want to get those click coordinates relative to the map, you can use the following code:
const map = event.target.getBoundingClientRect();
const x = event.clientX - map.left
const y = event.clientY - map.top;
console.log(x, y)