Skip to content

Commit 03bd74d

Browse files
committed
feat: add compatible constructor for marker ClickEvent
1 parent f5d3e00 commit 03bd74d

1 file changed

Lines changed: 27 additions & 1 deletion

File tree

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

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,34 @@ public static class GoogleMapMarkerClickEvent extends ClickEvent<GoogleMapMarker
299299
private final double lat;
300300
private final double lon;
301301

302+
/**
303+
* Creates a new event with the click coordinates as separate lat/lon values.
304+
*
305+
* @param source the marker that was clicked
306+
* @param fromClient whether the event originated on the client side
307+
* @param lat the latitude of the click
308+
* @param lon the longitude of the click
309+
*/
302310
public GoogleMapMarkerClickEvent(GoogleMapMarker source, boolean fromClient,
303-
@EventData(value = "event.detail.latLng") JsonValue latLng) {
311+
@EventData("event.detail.latLng.lat()") double lat,
312+
@EventData("event.detail.latLng.lng()") double lon) {
313+
super(source);
314+
this.lat = lat;
315+
this.lon = lon;
316+
}
317+
318+
/**
319+
* Creates a new event with the click coordinates as a JSON value.
320+
*
321+
* @param source the marker that was clicked
322+
* @param fromClient whether the event originated on the client side
323+
* @param latLng a JSON object containing {@code lat} and {@code lng} properties
324+
* @deprecated since 2.6.0, for removal. Use
325+
* {@link #GoogleMapMarkerClickEvent(GoogleMapMarker, boolean, double, double)} instead.
326+
*/
327+
@Deprecated
328+
public GoogleMapMarkerClickEvent(GoogleMapMarker source, boolean fromClient,
329+
JsonValue latLng) {
304330
super(source);
305331
this.lat = ((JsonObject) latLng).getNumber("lat");
306332
this.lon = ((JsonObject) latLng).getNumber("lng");

0 commit comments

Comments
 (0)