Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update map after adding/removing polygons and polylines #120

Merged
merged 2 commits into from
Mar 14, 2024
Merged
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 @@ -148,34 +148,76 @@ 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<GoogleMapPoint> points) {
GoogleMapPolygon polygon = new GoogleMapPolygon(points);
this.getElement().appendChild(polygon.getElement());
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) {
this.getElement().executeJs("this._updateObjects()");
}
}

/**
* 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<GoogleMapPoint> points) {
GoogleMapPolyline polyline = new GoogleMapPolyline(points);
this.getElement().appendChild(polyline.getElement());
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) {
this.getElement().executeJs("this._updateObjects()");
}
}

/**
* 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());
this.getElement().executeJs("this._updateObjects()");
}

/**
Expand Down
Loading