Skip to content

Commit f5d3e00

Browse files
committed
feat: add compatible constructor for marker RightClickEvent
1 parent a7e7146 commit f5d3e00

1 file changed

Lines changed: 59 additions & 1 deletion

File tree

src/main/java/com/flowingcode/vaadin/addons/googlemaps/GoogleMapMarker.java

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,24 @@ public static class GoogleMapMarkerRightClickEvent extends ClickEvent<GoogleMapM
336336
private final double lat;
337337
private final double lon;
338338

339+
/**
340+
* Creates a new event with the right click coordinates as separate lat/lon values.
341+
*
342+
* @param source the marker that was right clicked
343+
* @param fromClient whether the event originated on the client side
344+
* @param screenX the screen X coordinate of the click
345+
* @param screenY the screen Y coordinate of the click
346+
* @param clientX the client X coordinate of the click
347+
* @param clientY the client Y coordinate of the click
348+
* @param clickCount the click count
349+
* @param button the mouse button
350+
* @param ctrlKey whether Ctrl key was pressed
351+
* @param shiftKey whether Shift key was pressed
352+
* @param altKey whether Alt key was pressed
353+
* @param metaKey whether Meta key was pressed
354+
* @param lat the latitude of the click
355+
* @param lon the longitude of the click
356+
*/
339357
public GoogleMapMarkerRightClickEvent(GoogleMapMarker source, boolean fromClient,
340358
@EventData("event.detail.domEvent.screenX") int screenX,
341359
@EventData("event.detail.domEvent.screenY") int screenY,
@@ -347,7 +365,47 @@ public GoogleMapMarkerRightClickEvent(GoogleMapMarker source, boolean fromClient
347365
@EventData("event.detail.domEvent.shiftKey") boolean shiftKey,
348366
@EventData("event.detail.domEvent.altKey") boolean altKey,
349367
@EventData("event.detail.domEvent.metaKey") boolean metaKey,
350-
@EventData(value = "event.detail.latLng") JsonValue latLng) {
368+
@EventData("event.detail.latLng.lat()") double lat,
369+
@EventData("event.detail.latLng.lng()") double lon) {
370+
super(source, fromClient, screenX, screenY, clientX, clientY, clickCount, button, ctrlKey,
371+
shiftKey, altKey, metaKey);
372+
this.lat = lat;
373+
this.lon = lon;
374+
}
375+
376+
/**
377+
* Creates a new event with the right click coordinates as a JSON value.
378+
*
379+
* @param source the marker that was right clicked
380+
* @param fromClient whether the event originated on the client side
381+
* @param screenX the screen X coordinate of the click
382+
* @param screenY the screen Y coordinate of the click
383+
* @param clientX the client X coordinate of the click
384+
* @param clientY the client Y coordinate of the click
385+
* @param clickCount the click count
386+
* @param button the mouse button
387+
* @param ctrlKey whether Ctrl key was pressed
388+
* @param shiftKey whether Shift key was pressed
389+
* @param altKey whether Alt key was pressed
390+
* @param metaKey whether Meta key was pressed
391+
* @param latLng a JSON object containing {@code lat} and {@code lng} properties
392+
* @deprecated since 2.6.0, for removal. Use
393+
* {@link #GoogleMapMarkerRightClickEvent(GoogleMapMarker, boolean, int, int, int, int, int, int, boolean, boolean, boolean, boolean, double, double)}
394+
* instead.
395+
*/
396+
@Deprecated
397+
public GoogleMapMarkerRightClickEvent(GoogleMapMarker source, boolean fromClient,
398+
@EventData("event.detail.domEvent.screenX") int screenX,
399+
@EventData("event.detail.domEvent.screenY") int screenY,
400+
@EventData("event.detail.domEvent.clientX") int clientX,
401+
@EventData("event.detail.domEvent.clientY") int clientY,
402+
@EventData("event.detail.domEvent.detail") int clickCount,
403+
@EventData("event.detail.domEvent.button") int button,
404+
@EventData("event.detail.domEvent.ctrlKey") boolean ctrlKey,
405+
@EventData("event.detail.domEvent.shiftKey") boolean shiftKey,
406+
@EventData("event.detail.domEvent.altKey") boolean altKey,
407+
@EventData("event.detail.domEvent.metaKey") boolean metaKey,
408+
JsonValue latLng) {
351409
super(source, fromClient, screenX, screenY, clientX, clientY, clickCount, button, ctrlKey,
352410
shiftKey, altKey, metaKey);
353411
this.lat = ((JsonObject) latLng).getNumber("lat");

0 commit comments

Comments
 (0)