From 3af40c70923e8555eea2cce892796d66045e6556 Mon Sep 17 00:00:00 2001 From: Paola De Bartolo Date: Mon, 11 Mar 2024 14:48:42 -0300 Subject: [PATCH 1/2] fix: update map after adding/removing polygons and polylines Close #118 --- .../vaadin/addons/googlemaps/GoogleMap.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/flowingcode/vaadin/addons/googlemaps/GoogleMap.java b/src/main/java/com/flowingcode/vaadin/addons/googlemaps/GoogleMap.java index 2b317a3..72ca6b3 100644 --- a/src/main/java/com/flowingcode/vaadin/addons/googlemaps/GoogleMap.java +++ b/src/main/java/com/flowingcode/vaadin/addons/googlemaps/GoogleMap.java @@ -150,32 +150,40 @@ public GoogleMapMarker addMarker( public GoogleMapPolygon addPolygon(List points) { GoogleMapPolygon polygon = new GoogleMapPolygon(points); - this.getElement().appendChild(polygon.getElement()); + addPolygon(polygon); return polygon; } public void addPolygon(GoogleMapPolygon polygon) { this.getElement().appendChild(polygon.getElement()); + if (this.getElement().getParent() != null) { + this.getElement().executeJs("this._updateObjects()"); + } } @SuppressWarnings("squid:S3242") public void removePolygon(GoogleMapPolygon polygon) { this.getElement().removeChild(polygon.getElement()); + this.getElement().executeJs("this._updateObjects()"); } public GoogleMapPolyline addPolyline(List points) { GoogleMapPolyline polyline = new GoogleMapPolyline(points); - this.getElement().appendChild(polyline.getElement()); + addPolyline(polyline); return polyline; } public void addPolyline(GoogleMapPolyline polyline) { this.getElement().appendChild(polyline.getElement()); + if (this.getElement().getParent() != null) { + this.getElement().executeJs("this._updateObjects()"); + } } @SuppressWarnings("squid:S3242") public void removePolyline(GoogleMapPolyline polyline) { this.getElement().removeChild(polyline.getElement()); + this.getElement().executeJs("this._updateObjects()"); } /** From 8dcb3111bbcca54e95e4df62aea56ed3c8b9be4f Mon Sep 17 00:00:00 2001 From: Paola De Bartolo Date: Mon, 11 Mar 2024 14:53:51 -0300 Subject: [PATCH 2/2] chore: add missing javadocs --- .../vaadin/addons/googlemaps/GoogleMap.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/main/java/com/flowingcode/vaadin/addons/googlemaps/GoogleMap.java b/src/main/java/com/flowingcode/vaadin/addons/googlemaps/GoogleMap.java index 72ca6b3..c8752fa 100644 --- a/src/main/java/com/flowingcode/vaadin/addons/googlemaps/GoogleMap.java +++ b/src/main/java/com/flowingcode/vaadin/addons/googlemaps/GoogleMap.java @@ -148,12 +148,24 @@ public GoogleMapMarker addMarker( return gmm; } + /** + * Creates a polygon with the given points and adds the new polygon to the map. + * + * @param points the points of the polygon + * + * @return the new created polygon + */ public GoogleMapPolygon addPolygon(List points) { GoogleMapPolygon polygon = new GoogleMapPolygon(points); addPolygon(polygon); return polygon; } + /** + * Adds a new polygon to the map. + * + * @param polygon the polygon to be added to the map + */ public void addPolygon(GoogleMapPolygon polygon) { this.getElement().appendChild(polygon.getElement()); if (this.getElement().getParent() != null) { @@ -161,18 +173,35 @@ public void addPolygon(GoogleMapPolygon polygon) { } } + /** + * Removes a polygon from the map. + * + * @param polygon the polygon to be removed from the map + */ @SuppressWarnings("squid:S3242") public void removePolygon(GoogleMapPolygon polygon) { this.getElement().removeChild(polygon.getElement()); this.getElement().executeJs("this._updateObjects()"); } + /** + * Creates a polyline with the given points and adds the new polyline to the map. + * + * @param points the points of the polyline + * + * @return the new created polyline + */ public GoogleMapPolyline addPolyline(List points) { GoogleMapPolyline polyline = new GoogleMapPolyline(points); addPolyline(polyline); return polyline; } + /** + * Adds a new polyline to the map. + * + * @param polyline the polyline to be added to the map + */ public void addPolyline(GoogleMapPolyline polyline) { this.getElement().appendChild(polyline.getElement()); if (this.getElement().getParent() != null) { @@ -180,6 +209,11 @@ public void addPolyline(GoogleMapPolyline polyline) { } } + /** + * Removes a polyline from the map. + * + * @param polyline the polyline to be removed from the map + */ @SuppressWarnings("squid:S3242") public void removePolyline(GoogleMapPolyline polyline) { this.getElement().removeChild(polyline.getElement());