MapPolygon (API Reference)
Class MapPolygon
A visual representation of a polygon on the map. Can be used to visualize areas of all shapes and sizes.
The geometry to be visualized is represented by an instance of GeoPolygon.
To display circular areas (for example, a position accuracy indicator) use a GeoPolygon
created from a GeoCircle using GeoPolygon(GeoCircle).
Note:
- The polygon shape should not cover more than half of the globe, otherwise unexpected results may occur.
- Polygons which are self-intersecting are not supported and may lead to render artifacts.
- The inner boundaries (holes) specified in the GeoPolygon are ignored.
-
Constructor Summary
ConstructorsConstructorDescriptionMapPolygon(GeoPolygon geometry, Color color) Creates a new MapPolygon instance with outline visualization disabled and containing the geometry passed in.MapPolygon(GeoPolygon geometry, Color color, Color outlineColor, double outlineWidthInPixels) Creates a new MapPolygon instance with outline visualization enabled and containing the geometry passed in. -
Method Summary
Modifier and TypeMethodDescriptionintGets the draw order of this map polygon relative to other map polygons.Gets the current color of the fill.Gets the current geometry of the polygon.Gets the Metadata instance attached to this polygon.Gets the color of the polygon outline.doubleGets the outline width of the polygon in pixels.Gets the list of visibility ranges.voidsetDrawOrder(int value) Sets the draw order of this map polygon relative to other map polygons.voidsetFillColor(Color value) Sets the current color of the fill.voidsetGeometry(GeoPolygon value) Sets a new geometry to update the appearance.voidsetMetadata(Metadata value) Sets the Metadata instance to be attached to this polygon.voidsetOutlineColor(Color value) Sets the color of the polygon outline.voidsetOutlineWidth(double value) Sets the outline width of the polygon in pixels.voidsetVisibilityRanges(List<MapMeasureRange> value) Sets visibility ranges for this map polygon.
-
Constructor Details
-
MapPolygon
Creates a new MapPolygon instance with outline visualization disabled and containing the geometry passed in.
The winding order of the vertices can be in clockwise or counter-clockwise order. It is recomended to provide the outer boundary ordered clockwise and closed.
Note:
- The polygon shape should not cover more than half of the globe, otherwise unexpected results may occur.
- Polygons which are self-intersecting are not supported and may lead to render artifacts.
- The inner boundaries (holes) specified in the GeoPolygon are ignored.
- Parameters:
geometry-The list of vertices representing the outer boundary of polygon.
color-The fill color for the polygon
-
MapPolygon
public MapPolygon(@NonNull GeoPolygon geometry, @NonNull Color color, @NonNull Color outlineColor, double outlineWidthInPixels) Creates a new MapPolygon instance with outline visualization enabled and containing the geometry passed in.
Transparent outlines are not supported. Any color with transparency (alpha value other than 1) will be rendered as fully opaque by interpreting the alpha value as 1.
The winding order of the vertices can be in clockwise or counter-clockwise order. It is recomended to provide the outer boundary ordered clockwise and closed.
Note:
- The polygon shape should not cover more than half of the globe, otherwise unexpected results may occur.
- Polygons which are self-intersecting are not supported and may lead to render artifacts.
- The inner boundaries (holes) specified in the GeoPolygon are ignored.
- Parameters:
geometry-The list of vertices representing the outer boundary of polygon.
color-The fill color for the polygon.
outlineColor-The color of the polygon outline, alpha channel is ignored and treated as 1.
outlineWidthInPixels-The width of the polygon outline (in pixels). Negative values are clamped to 0.
-
-
Method Details
-
getGeometry
Gets the current geometry of the polygon.
- Returns:
The geometry of the polygon. Setting a new geometry will update the appearance.
-
setGeometry
Sets a new geometry to update the appearance.
The winding order of the vertices can be in clockwise or counter-clockwise order. It is recomended to provide the outer boundary ordered clockwise and closed.
Note:
- The polygon shape should not cover more than half of the globe, otherwise unexpected results may occur.
- Polygons which are self-intersecting are not supported and may lead to render artifacts.
- The inner boundaries (holes) specified in the GeoPolygon are ignored.
- Parameters:
value-The geometry of the polygon. Setting a new geometry will update the appearance.
-
getMetadata
Gets the Metadata instance attached to this polygon.
- Returns:
The Metadata instance attached to this polygon,
nullby default.
-
setMetadata
Sets the Metadata instance to be attached to this polygon.
- Parameters:
value-The Metadata instance attached to this polygon,
nullby default.
-
getFillColor
Gets the current color of the fill.
- Returns:
Color of the polygon's fill.
-
setFillColor
Sets the current color of the fill.
Fully transparent color (alpha set to 0) disables the fill completely.
- Parameters:
value-Color of the polygon's fill.
-
getDrawOrder
public int getDrawOrder()Gets the draw order of this map polygon relative to other map polygons. Default value is 0.
- Returns:
The draw order of this map polygon relative to other map polygons.
-
setDrawOrder
public void setDrawOrder(int value) Sets the draw order of this map polygon relative to other map polygons.
Polygon with higher draw order value are drawn on top of polygons with lower draw order.
In case multiple polygons have the same draw order value then the order in which they were added to the scene matters. Last added polygon is drawn on top.
Allowed range is 0-1023. Values outside this range will be clamped.
- Parameters:
value-The draw order of this map polygon relative to other map polygons.
-
getVisibilityRanges
Gets the list of visibility ranges. The map polygon is visible only inside these map measure ranges. When empty (the default), the map polygon is visible without map measure restrictions.
- Returns:
The list of visibility ranges. The map polygon is visible only inside these map measure ranges.
-
setVisibilityRanges
Sets visibility ranges for this map polygon. A range is half open - [minimumZoomLevel, maximumZoomLevel), the given maximum value is not contained in the range. The map polygon is visible only inside these map measure ranges.
When empty (the default), the map polygon is visible without map measure restrictions. Only
MapMeasureRange(s) ofMapMeasure.Kind.ZOOM_LEVELtype are supported.MapMeasureRange(s) of other unsupported types will be ignored.- Parameters:
value-The list of visibility ranges. The map polygon is visible only inside these map measure ranges.
-
getOutlineColor
Gets the color of the polygon outline. The default outline color is opaque white.
- Returns:
The color of the polygon outline.
-
setOutlineColor
Sets the color of the polygon outline.
Transparent outlines are not supported. Any color with transparency (alpha value other than 1) will be rendered as fully opaque.
- Parameters:
value-The color of the polygon outline.
-
getOutlineWidth
public double getOutlineWidth()Gets the outline width of the polygon in pixels.
By default, the outline width is set to zero.
- Returns:
The width of the polygon outline in pixels.
-
setOutlineWidth
public void setOutlineWidth(double value) Sets the outline width of the polygon in pixels.
The value should be greater than or equal to 0. Negative values are clamped to zero.
- Parameters:
value-The width of the polygon outline in pixels.
-