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
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import lombok.experimental.ExtensionMethod;
import org.apache.commons.lang3.StringUtils;

@SuppressWarnings("serial")
Expand All @@ -54,6 +55,7 @@
@NpmPackage(value = "@flowingcode/google-map", version = "3.9.0")
@NpmPackage(value = "@googlemaps/markerclusterer", version = "2.0.8")
@JsModule("./googlemaps/geolocation.js")
@ExtensionMethod(value = JsonMigration.class, suppressBaseMethods = true)
public class GoogleMap extends Component implements HasSize {

private Integer trackLocationId = null;
Expand Down Expand Up @@ -519,7 +521,7 @@ public Registration addClickListener(ComponentEventListener<GoogleMapClickEvent>
DomListenerRegistration registration =
getElement()
.addEventListener("google-map-click", ev -> {
JsonObject latLng = JsonMigration.getEventData(ev).get("event.detail.latLng");
JsonObject latLng = ev.getEventData().get("event.detail.latLng");
listener.onComponentEvent(new GoogleMapClickEvent(this, true, latLng));
}).addEventData("event.detail.latLng");
return registration::remove;
Expand All @@ -531,7 +533,7 @@ public Registration addRightClickListener(ComponentEventListener<GoogleMapClickE
DomListenerRegistration registration =
getElement()
.addEventListener("google-map-rightclick", ev -> {
JsonObject latLng = JsonMigration.getEventData(ev).get("event.detail.latLng");
JsonObject latLng = ev.getEventData().get("event.detail.latLng");
listener.onComponentEvent(new GoogleMapClickEvent(this, true, latLng));
}).addEventData("event.detail.latLng");
return registration::remove;
Expand Down Expand Up @@ -768,7 +770,7 @@ public Registration addGoogleMapBoundsChangedListener(
DomListenerRegistration registration =
getElement().addEventListener("google-map-bounds_changed", ev -> {
listener.onComponentEvent(new GoogleMapBoundsChangedEvent(this, true,
new LatLonBounds(JsonMigration.getEventData(ev).get("event.detail"))));
new LatLonBounds(ev.getEventData().get("event.detail"))));
}).debounce(1000, DebouncePhase.TRAILING).addEventData("event.detail");
return registration::remove;
}
Expand Down Expand Up @@ -804,7 +806,7 @@ public void addCustomControls(CustomControl... customControls) {
customControl.getControlButton().getElement().setAttribute("slot", "customControlSlot_" + i);
getElement().appendChild(customControl.getControlButton().getElement());
}
JsonMigration.setPropertyJson(getElement(), "customControls", jsonArray);
getElement().setPropertyJson("customControls", jsonArray);
}

/**
Expand All @@ -823,7 +825,7 @@ public void setCustomControls(CustomControl... customControls) {
getElement().appendChild(customControl.getControlButton().getElement());
this.customControls.add(customControl);
}
JsonMigration.setPropertyJson(getElement(), "customControls", jsonArray);
getElement().setPropertyJson("customControls", jsonArray);
});
}

Expand Down Expand Up @@ -925,6 +927,6 @@ public void setMapStyle(MapStyle... mapStyles) {
MapStyle mapStyle = mapStyles[i];
jsonArray.set(i, mapStyle.getJson());
}
JsonMigration.setPropertyJson(getElement(), "styles", jsonArray);
getElement().setPropertyJson("styles", jsonArray);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@
import com.vaadin.flow.shared.Registration;
import elemental.json.JsonObject;
import elemental.json.JsonValue;
import lombok.experimental.ExtensionMethod;

/** The class representing a marker of the Google Map. */
@SuppressWarnings("serial")
@Tag("google-map-marker")
@JsModule("@flowingcode/google-map/google-map-marker.js")
@NpmPackage(value = "@flowingcode/google-map", version = "3.9.0")
@NpmPackage(value = "@googlemaps/markerclusterer", version = "2.0.8")
@ExtensionMethod(value = JsonMigration.class, suppressBaseMethods = true)
public class GoogleMapMarker extends Component {

private static long idCounter = 0;
Expand Down Expand Up @@ -194,7 +196,7 @@ public void setIconUrl(String iconUrl) {
* @param icon the icon image of the marker
*/
public void setIcon(GoogleMapIcon icon) {
JsonMigration.setPropertyJson(getElement(), "icon", icon.getJson());
this.getElement().setPropertyJson("icon", icon.getJson());
}

/**
Expand All @@ -204,7 +206,7 @@ public void setIcon(GoogleMapIcon icon) {
* @param label the new marker's label
*/
public void setLabel(MarkerLabel label) {
JsonMigration.setPropertyJson(getElement(), "label", label.getJson());
this.getElement().setPropertyJson("label", label.getJson());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@
import elemental.json.JsonObject;
import elemental.json.JsonValue;
import java.util.List;
import lombok.experimental.ExtensionMethod;

@SuppressWarnings("serial")
@Tag("google-map-poly")
@JsModule("@flowingcode/google-map/google-map-poly.js")
@JsModule("@flowingcode/google-map/google-map-point.js")
@NpmPackage(value = "@flowingcode/google-map", version = "3.9.0")
@NpmPackage(value = "@googlemaps/markerclusterer", version = "2.0.8")
@ExtensionMethod(value = JsonMigration.class, suppressBaseMethods = true)
public abstract class GoogleMapPoly extends Component {

private static final double DEFAULT_FILL_OPACITY = 0.5d;
Expand Down Expand Up @@ -192,7 +194,7 @@ public void setIcons(Icon... icons) {
for (int i = 0; i < icons.length; i++) {
jsonArray.set(i, icons[i].getJson());
}
JsonMigration.setPropertyJson(getElement(), "icons", jsonArray);
getElement().setPropertyJson("icons", jsonArray);
}

/**
Expand All @@ -205,7 +207,7 @@ public void setIcons(IconSequence... icons) {
for (int i = 0; i < icons.length; i++) {
jsonArray.set(i, icons[i].getJson());
}
JsonMigration.setPropertyJson(getElement(), "icons", jsonArray);
getElement().setPropertyJson("icons", jsonArray);
}

}