Hi guys, great component! Any ideia how show vaadin components (like a ContextMenu for example) clicking on a marker? addInfoWindow(Html) allows only plain HTML
Hi, you could add a click event listener to the marker and then execute whatever you want on click, but not sure about how a ContextMenu can be added in that scenario. There’s no Java API for adding click listeners to markers yet but it can be done, for example, like this:
marker.getElement().setProperty("clickEvents", true);
marker.getElement().setProperty("clickable", true);
marker.getElement().addEventListener("google-map-marker-click", event -> {
JsonObject eventData = event.getEventData();
JsonObject latLng = eventData.getObject("event.detail.latLng");
Notification.show("Marker was clicked at latitude: " + latLng.getNumber("lat") + " - longitude: " + latLng.getNumber("lng"));
}).addEventData("event.detail.latLng");
I will create a ticket to add the click event listener to the markers as it would be a great addition to the add-on.
Regards.
Hi Paola!
Thanks for your reply!
This will help me a lot.
I think the listener implementation will be very appreciated too.
Hello, the listener is now part of the Java API as part of our latest released version: 1.6.0.
Regards.