diff options
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Polygon.java')
-rw-r--r-- | platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Polygon.java | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Polygon.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Polygon.java index 4a72cb7d89..9245d9cdc8 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Polygon.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Polygon.java @@ -4,6 +4,9 @@ import android.graphics.Color; import com.mapbox.mapboxsdk.maps.MapboxMap; +import java.util.ArrayList; +import java.util.List; + /** * Polygon is a geometry annotation that's a closed loop of coordinates. */ @@ -11,9 +14,11 @@ public final class Polygon extends BasePointCollection { private int fillColor = Color.BLACK; // default fillColor is black private int strokeColor = Color.BLACK; // default strokeColor is black + private List<Hole> holes; Polygon() { super(); + holes = new ArrayList<>(); } /** @@ -26,7 +31,7 @@ public final class Polygon extends BasePointCollection { } /** - * Get the color fo the stroke of the polygon. + * Get the color of the stroke of the polygon. * * @return The color of the stroke. */ @@ -35,6 +40,15 @@ public final class Polygon extends BasePointCollection { } /** + * Returns a copy of the holes. + * + * @return A {@link List} of holes. + */ + public List<Hole> getHoles() { + return new ArrayList<>(holes); + } + + /** * Sets the color of the fill region of the polygon. * * @param color The color in ARGB format. @@ -54,6 +68,27 @@ public final class Polygon extends BasePointCollection { update(); } + /** + * Sets the holes of this polygon. This method will take a copy of the holes, so further + * mutations to holes will have no effect on this polygon. + * + * @param holes A {@link List} of {@link Hole} points making up the holes. + */ + public void setHoles(List<? extends Hole> holes) { + this.holes = new ArrayList<>(holes); + update(); + } + + /** + * Add a hole to the polygon. + * + * @param hole A {@link Hole} hole to be added. + */ + void addHole(Hole hole) { + holes.add(hole); + update(); + } + @Override void update() { MapboxMap mapboxMap = getMapboxMap(); |