Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.flowingcode.vaadin.addons</groupId>
<artifactId>google-maps</artifactId>
<version>2.5.1-SNAPSHOT</version>
<version>2.6.0-SNAPSHOT</version>
<name>Google Maps Addon</name>
<description>Integration of google-map for Vaadin platform</description>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -508,10 +508,38 @@ public double getLongitude() {
return lon;
}

/**
* Creates a new event with the click coordinates as separate lat/lon values.
*
* @param source the map that was clicked
* @param fromClient whether the event originated on the client side
* @param lat the latitude of the click
* @param lon the longitude of the click
*/
public GoogleMapClickEvent(
GoogleMap source,
boolean fromClient,
@EventData("event.detail.latLng.lat()") double lat,
@EventData("event.detail.latLng.lng()") double lon) {
super(source);
this.lat = lat;
this.lon = lon;
}

/**
* Creates a new event with the click coordinates as a JSON value.
*
* @param source the map that was clicked
* @param fromClient whether the event originated on the client side
* @param latLng a JSON object containing {@code lat} and {@code lng} properties
* @deprecated since 2.6.0, for removal. Use
* {@link #GoogleMapClickEvent(GoogleMap, boolean, double, double)} instead.
*/
@Deprecated
public GoogleMapClickEvent(
GoogleMap source,
boolean fromClient,
@EventData(value = "event.detail.latLng") JsonValue latLng) {
JsonValue latLng) {
super(source);
lat = ((JsonObject) latLng).getNumber("lat");
lon = ((JsonObject) latLng).getNumber("lng");
Expand All @@ -525,7 +553,9 @@ public Registration addClickListener(ComponentEventListener<GoogleMapClickEvent>
getElement()
.addEventListener("google-map-click", ev -> {
JsonObject latLng = ev.getEventData().get("event.detail.latLng");
listener.onComponentEvent(new GoogleMapClickEvent(this, true, latLng));
double lat = latLng.getNumber("lat");
double lon = latLng.getNumber("lng");
listener.onComponentEvent(new GoogleMapClickEvent(this, true, lat, lon));
}).addEventData("event.detail.latLng");
return registration::remove;
}
Expand All @@ -537,7 +567,9 @@ public Registration addRightClickListener(ComponentEventListener<GoogleMapClickE
getElement()
.addEventListener("google-map-rightclick", ev -> {
JsonObject latLng = ev.getEventData().get("event.detail.latLng");
listener.onComponentEvent(new GoogleMapClickEvent(this, true, latLng));
double lat = latLng.getNumber("lat");
double lon = latLng.getNumber("lng");
listener.onComponentEvent(new GoogleMapClickEvent(this, true, lat, lon));
}).addEventData("event.detail.latLng");
return registration::remove;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,38 @@ public static class DragEndEvent extends ComponentEvent<GoogleMapMarker> {
private final double lat;
private final double lon;

/**
* Creates a new event with the drag end coordinates as separate lat/lon values.
*
* @param source the marker that was dragged
* @param fromClient whether the event originated on the client side
* @param lat the latitude of the drag end
* @param lon the longitude of the drag end
*/
public DragEndEvent(
GoogleMapMarker source,
boolean fromClient,
@EventData(value = "event.detail.latLng") JsonValue latLng) {
@EventData("event.detail.latLng.lat()") double lat,
@EventData("event.detail.latLng.lng()") double lon) {
super(source, fromClient);
this.lat = lat;
this.lon = lon;
}

/**
* Creates a new event with the drag end coordinates as a JSON value.
*
* @param source the marker that was dragged
* @param fromClient whether the event originated on the client side
* @param latLng a JSON object containing {@code lat} and {@code lng} properties
* @deprecated since 2.6.0, for removal. Use
* {@link #DragEndEvent(GoogleMapMarker, boolean, double, double)} instead.
*/
@Deprecated
public DragEndEvent(
GoogleMapMarker source,
boolean fromClient,
JsonValue latLng) {
super(source, fromClient);
this.lat = ((JsonObject) latLng).getNumber("lat");
this.lon = ((JsonObject) latLng).getNumber("lng");
Expand Down Expand Up @@ -299,8 +327,34 @@ public static class GoogleMapMarkerClickEvent extends ClickEvent<GoogleMapMarker
private final double lat;
private final double lon;

/**
* Creates a new event with the click coordinates as separate lat/lon values.
*
* @param source the marker that was clicked
* @param fromClient whether the event originated on the client side
* @param lat the latitude of the click
* @param lon the longitude of the click
*/
public GoogleMapMarkerClickEvent(GoogleMapMarker source, boolean fromClient,
@EventData(value = "event.detail.latLng") JsonValue latLng) {
@EventData("event.detail.latLng.lat()") double lat,
@EventData("event.detail.latLng.lng()") double lon) {
super(source);
this.lat = lat;
this.lon = lon;
}

/**
* Creates a new event with the click coordinates as a JSON value.
*
* @param source the marker that was clicked
* @param fromClient whether the event originated on the client side
* @param latLng a JSON object containing {@code lat} and {@code lng} properties
* @deprecated since 2.6.0, for removal. Use
* {@link #GoogleMapMarkerClickEvent(GoogleMapMarker, boolean, double, double)} instead.
*/
@Deprecated
public GoogleMapMarkerClickEvent(GoogleMapMarker source, boolean fromClient,
JsonValue latLng) {
super(source);
this.lat = ((JsonObject) latLng).getNumber("lat");
this.lon = ((JsonObject) latLng).getNumber("lng");
Expand Down Expand Up @@ -336,6 +390,64 @@ public static class GoogleMapMarkerRightClickEvent extends ClickEvent<GoogleMapM
private final double lat;
private final double lon;

/**
* Creates a new event with the right click coordinates as separate lat/lon values.
*
* @param source the marker that was right clicked
* @param fromClient whether the event originated on the client side
* @param screenX the screen X coordinate of the click
* @param screenY the screen Y coordinate of the click
* @param clientX the client X coordinate of the click
* @param clientY the client Y coordinate of the click
* @param clickCount the click count
* @param button the mouse button
* @param ctrlKey whether Ctrl key was pressed
* @param shiftKey whether Shift key was pressed
* @param altKey whether Alt key was pressed
* @param metaKey whether Meta key was pressed
* @param lat the latitude of the click
* @param lon the longitude of the click
*/
public GoogleMapMarkerRightClickEvent(GoogleMapMarker source, boolean fromClient,
@EventData("event.detail.domEvent.screenX") int screenX,
@EventData("event.detail.domEvent.screenY") int screenY,
@EventData("event.detail.domEvent.clientX") int clientX,
@EventData("event.detail.domEvent.clientY") int clientY,
@EventData("event.detail.domEvent.detail") int clickCount,
@EventData("event.detail.domEvent.button") int button,
@EventData("event.detail.domEvent.ctrlKey") boolean ctrlKey,
@EventData("event.detail.domEvent.shiftKey") boolean shiftKey,
@EventData("event.detail.domEvent.altKey") boolean altKey,
@EventData("event.detail.domEvent.metaKey") boolean metaKey,
@EventData("event.detail.latLng.lat()") double lat,
@EventData("event.detail.latLng.lng()") double lon) {
super(source, fromClient, screenX, screenY, clientX, clientY, clickCount, button, ctrlKey,
shiftKey, altKey, metaKey);
this.lat = lat;
this.lon = lon;
}

/**
* Creates a new event with the right click coordinates as a JSON value.
*
* @param source the marker that was right clicked
* @param fromClient whether the event originated on the client side
* @param screenX the screen X coordinate of the click
* @param screenY the screen Y coordinate of the click
* @param clientX the client X coordinate of the click
* @param clientY the client Y coordinate of the click
* @param clickCount the click count
* @param button the mouse button
* @param ctrlKey whether Ctrl key was pressed
* @param shiftKey whether Shift key was pressed
* @param altKey whether Alt key was pressed
* @param metaKey whether Meta key was pressed
* @param latLng a JSON object containing {@code lat} and {@code lng} properties
* @deprecated since 2.6.0, for removal. Use
* {@link #GoogleMapMarkerRightClickEvent(GoogleMapMarker, boolean, int, int, int, int, int, int, boolean, boolean, boolean, boolean, double, double)}
* instead.
*/
@Deprecated
public GoogleMapMarkerRightClickEvent(GoogleMapMarker source, boolean fromClient,
@EventData("event.detail.domEvent.screenX") int screenX,
@EventData("event.detail.domEvent.screenY") int screenY,
Expand All @@ -347,7 +459,7 @@ public GoogleMapMarkerRightClickEvent(GoogleMapMarker source, boolean fromClient
@EventData("event.detail.domEvent.shiftKey") boolean shiftKey,
@EventData("event.detail.domEvent.altKey") boolean altKey,
@EventData("event.detail.domEvent.metaKey") boolean metaKey,
@EventData(value = "event.detail.latLng") JsonValue latLng) {
JsonValue latLng) {
super(source, fromClient, screenX, screenY, clientX, clientY, clickCount, button, ctrlKey,
shiftKey, altKey, metaKey);
this.lat = ((JsonObject) latLng).getNumber("lat");
Expand Down
Loading