A circle on the earth's surface (spherical cap).
A circle has the following properties.
LatLng.Color. The
default value is black (0xff000000).null) or a sequence of PatternItem
objects to be repeated along the circle's outline. Available PatternItem
types: Gap (defined by
gap length in pixels), Dash (defined
by stroke width and dash length in pixels) and Dot (circular,
centered on the circle's outline, diameter defined by stroke width in pixels).Color. The
default value is transparent (0x00000000).GroundOverlays,
TileOverlays,
Polylines,
and Polygons but
not Markers). An
overlay with a larger z-index is drawn over overlays with smaller z-indices. The order of
overlays with the same z-index is arbitrary. The default zIndex is 0.true, i.e., visible.Object associated with the circle. For example, the Object
can contain data about what the circle represents. This is easier than storing a separate
Map<Circle, Object>. As another example, you can associate a
String ID corresponding to the ID from a data set. Google Maps SDK for Android
neither reads nor writes this property.Methods in this class must be called on the Android UI thread. If not, an IllegalStateException
will be thrown at runtime.
GoogleMap map;
// ... get a map.
// Add a circle in Sydney
Circle circle = map.addCircle(new CircleOptions()
.center(new LatLng(-33.87365, 151.20689))
.radius(10000)
.strokeColor(Color.RED)
.fillColor(Color.BLUE));
Note that the current map renderer is unable to draw the circle fill if the circle encompasses either the North or South pole. However, the outline will still be drawn correctly.
For more information, read the Shapes developer guide.
| LatLng | |
| int |
getFillColor()
Returns the fill color of this Circle.
|
| String |
getId()
Gets this circle's id.
|
| double |
getRadius()
Returns the circle's radius, in meters.
|
| int |
getStrokeColor()
Returns the stroke color.
|
| List<PatternItem> |
getStrokePattern()
Returns the stroke pattern of this circle's outline.
|
| float |
getStrokeWidth()
Returns the stroke width.
|
| Object |
getTag()
Gets the tag for the circle.
|
| float |
getZIndex()
Returns the zIndex.
|
| boolean |
isClickable()
Gets the clickability of the circle.
|
| boolean |
isVisible()
Checks whether the circle is visible.
|
| void |
remove()
Removes this circle from the map.
|
| void | |
| void |
setClickable(boolean clickable)
Sets the clickability of the circle.
|
| void |
setFillColor(int color)
Sets the fill color.
|
| void |
setRadius(double radius)
Sets the radius in meters.
|
| void |
setStrokeColor(int color)
Sets the stroke color.
|
| void | |
| void |
setStrokeWidth(float width)
Sets the stroke width.
|
| void | |
| void |
setVisible(boolean visible)
Sets the visibility of the circle.
|
| void |
setZIndex(float zIndex)
Sets the zIndex.
|
Returns the fill color of this Circle.
Gets this circle's id. The id will be unique amongst all Circles on a map.
Returns the circle's radius, in meters.
Returns the stroke color.
Returns the stroke pattern of this circle's outline.
null if default solid stroke pattern is
used.Returns the stroke width.
Gets the tag for the circle.
setTag(Object); null if no tag has been set.Returns the zIndex.
Gets the clickability of the circle. If the circle is clickable, your app will
receive notifications to the GoogleMap.OnCircleClickListener
when the user clicks the circle. The event listener is registered through
GoogleMap.setOnCircleClickListener(GoogleMap.OnCircleClickListener).
true if the circle is clickable; false if it is not
clickable.Checks whether the circle is visible.
true if the circle is visible; false if it is
invisible.Removes this circle from the map. After a circle has been removed, the behavior of all its methods is undefined.
Sets the center using a LatLng.
The center must not be null, as there is no default value.
| center | The geographic center of the circle, specified as a LatLng. |
|---|
| NullPointerException | if center is null. |
|---|
Sets the clickability of the circle. If the circle is clickable, your app will
receive notifications to the GoogleMap.OnCircleClickListener
when the user clicks the circle. The event listener is registered through
GoogleMap.setOnCircleClickListener(GoogleMap.OnCircleClickListener).
| clickable | New clickability setting for the circle. |
|---|
Sets the radius in meters.
The radius must be zero or greater.
| radius | The radius, in meters. |
|---|
| IllegalArgumentException | if radius is negative |
|---|
Sets the stroke pattern of the circle's outline. The default stroke pattern is
solid, represented by null.
| pattern | the stroke pattern. |
|---|
Sets the stroke width.
The stroke width is the width (in screen pixels) of the circle's outline. It must be zero or greater. If it is zero then no outline is drawn. The default value is 10.
| width | The stroke width, in screen pixels. |
|---|
| IllegalArgumentException | if width is negative |
|---|
Sets the tag for the circle.
You can use this property to associate an arbitrary Object with this
circle. For example, the Object can contain data about what the circle
represents. This is easier than storing a separate Map<Circle,
Object>. As another example, you can associate a String ID
corresponding to the ID from a data set. Google Maps SDK for Android neither reads nor
writes this property. It is your responsibility to call setTag(null) to
clear the tag when you no longer need it, to prevent memory leaks in your app.
| tag | if null, the tag is cleared. |
|---|
Sets the visibility of the circle.
If this circle is not visible then it will not be drawn. All other state is preserved. Circles are visible by default.
| visible | true to make this circle visible; false to make it
invisible. |
|---|
Sets the zIndex.
Overlays (such as circles) with higher zIndices are drawn above those with lower indices.
| zIndex | The zIndex value. |
|---|