FlowingCode / GoogleMapsAddon

Vaadin Addon based on Google Maps Web Component
https://www.flowingcode.com/en/open-source/
Apache License 2.0
20 stars 7 forks source link

right click on marker #67

Closed drakator closed 1 year ago

drakator commented 2 years ago

Hello, in version 1.6.0 I can't get right click event over marker (left click is working, but does not give me clickCounts, ctrl, shift, and alt keys)

best regards

paodb commented 2 years ago

Hello, currently the component doesn't have an API to handle right click on markers but the web-component has the event for that (google-map-marker-rightclick) so you could get the right click working with something like this:

marker.getElement().setProperty("clickEvents", true);
marker.getElement().setProperty("clickable", true);
marker.getElement().addEventListener("google-map-marker-rightclick", event -> {
   // do something here         
}).addEventData("event");

The only thing is that this returns a MapMouseEvent and it contains only two fields: domEvent & latLng.

paodb commented 2 years ago

I've investigated this a little bit more and I run into this example that I modified a little bit and shows that is possible to add a rightclick listener to a google map's marker and obtain some data like altKey, ctrlKey, shiftKey and metaKey (for Mac), Window-relative coordinates: clientX/clientY and document-relative coordinates: pageX/pageY. I think that we can implement something similar in our google-maps web component that is the base of this addon. Not sure if it's possible to obtain clickCounts.

google-maps-marker