Skip to content

Commit cbe6302

Browse files
paodbjavier-godoy
authored andcommitted
fix: update map after adding/removing polygons and polylines
Close #118
1 parent 4282e8e commit cbe6302

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,32 +150,40 @@ public GoogleMapMarker addMarker(
150150

151151
public GoogleMapPolygon addPolygon(List<GoogleMapPoint> points) {
152152
GoogleMapPolygon polygon = new GoogleMapPolygon(points);
153-
this.getElement().appendChild(polygon.getElement());
153+
addPolygon(polygon);
154154
return polygon;
155155
}
156156

157157
public void addPolygon(GoogleMapPolygon polygon) {
158158
this.getElement().appendChild(polygon.getElement());
159+
if (this.getElement().getParent() != null) {
160+
this.getElement().executeJs("this._updateObjects()");
161+
}
159162
}
160163

161164
@SuppressWarnings("squid:S3242")
162165
public void removePolygon(GoogleMapPolygon polygon) {
163166
this.getElement().removeChild(polygon.getElement());
167+
this.getElement().executeJs("this._updateObjects()");
164168
}
165169

166170
public GoogleMapPolyline addPolyline(List<GoogleMapPoint> points) {
167171
GoogleMapPolyline polyline = new GoogleMapPolyline(points);
168-
this.getElement().appendChild(polyline.getElement());
172+
addPolyline(polyline);
169173
return polyline;
170174
}
171175

172176
public void addPolyline(GoogleMapPolyline polyline) {
173177
this.getElement().appendChild(polyline.getElement());
178+
if (this.getElement().getParent() != null) {
179+
this.getElement().executeJs("this._updateObjects()");
180+
}
174181
}
175182

176183
@SuppressWarnings("squid:S3242")
177184
public void removePolyline(GoogleMapPolyline polyline) {
178185
this.getElement().removeChild(polyline.getElement());
186+
this.getElement().executeJs("this._updateObjects()");
179187
}
180188

181189
/**

0 commit comments

Comments
 (0)