目录

Circle

Class Info

public final class Circle

Defines a circle on a map. A circle can either be solid or hollow. An instance of this type will be returned when the addCircle method in the HuaweiMap class is called.

Public Method Summary

Qualifier and Type

Method Name and Description

boolean

clearAnimation()

Clears all animations.

LatLng

getCenter()

Obtains the latitude and longitude of the center of a circle.

int

getFillColor()

Obtains the fill color of a circle.

String

getId()

Obtains the ID of a circle on a map.

double

getRadius()

Obtains the radius of a circle.

int

getStrokeColor()

Obtains the stroke color of a circle's outline.

List<PatternItem>

getStrokePattern()

Obtains the stroke pattern of a circle's outline.

float

getStrokeWidth()

Obtains the stroke width of a circle's outline.

Object

getTag()

Obtains the tag attribute of a circle.

float

getZIndex()

Obtains the z-index of a circle.

boolean

isClickable()

Checks whether a circle is clickable.

boolean

isVisible()

Checks whether a circle is visible.

void

remove()

Removes a circle from a map. After the circle is removed, the behavior of its methods is invalid.

void

setAnimation(Animation animation)

Sets the animation for a circle.

void

setCenter(LatLng center)

Sets the longitude and latitude of the center of a circle.

void

setClickable(boolean clickable)

Sets whether a circle is clickable.

void

setFillColor(int color)

Sets the fill color of a circle.

void

setRadius(double radius)

Sets the radius of a circle.

void

setStrokeColor(int color)

Sets the stroke color of a circle's outline.

void

setStrokePattern(List<PatternItem> pattern)

Sets the stroke pattern of a circle's outline.

void

setStrokeWidth(float width)

Sets the stroke width of a circle's outline.

<T> void

setTag(T tag)

Sets the tag attribute of a circle.

void

setVisible(boolean visible)

Sets whether a circle is visible.

void

setZIndex(float zIndex)

Sets the z-index of a circle.

void

startAnimation()

Starts the animation.

Public Methods

[h2]clearAnimation

Method

public boolean clearAnimation()

Clears all animations.

Returns

Type

Description

boolean

true if all animations are cleared successfully; false otherwise.

[h2]getCenter

Method

public LatLng getCenter()

Obtains the latitude and longitude of the center of a circle.

Returns

Type

Description

LatLng

Longitude and latitude of the center of a circle.

[h2]getFillColor

Method

public int getFillColor()

Obtains the fill color of a circle.

Returns

Type

Description

int

Color in ARGB format.

[h2]getId

Method

public String getId()

Obtains the ID of a circle on a map. The ID will be unique among all circles on a map.

Returns

Type

Description

String

ID of a circle.

[h2]getRadius

Method

public double getRadius()

Obtains the radius of a circle.

Returns

Type

Description

double

Radius of a circle, in meters.

[h2]getStrokeColor

Method

public int getStrokeColor()

Obtains the stroke color of a circle's outline.

Returns

Type

Description

int

Color in ARGB format.

[h2]getStrokePattern

Method

public List<PatternItem> getStrokePattern()

Obtains the stroke pattern of a circle's outline.

Returns

Type

Description

List<PatternItem>

Stroke pattern of a circle's outline.

[h2]getStrokeWidth

Method

public float getStrokeWidth()

Obtains the stroke width of a circle's outline.

Returns

Type

Description

float

Stroke width of a circle's outline, in pixels.

[h2]getTag

Method

public Object getTag()

Obtains the tag attribute of a circle.

Returns

Type

Description

Object

Object if a tag has been set; null otherwise.

[h2]getZIndex

Method

public float getZIndex()

Obtains the z-index of a circle.

Returns

Type

Description

float

Z-index, which indicates the overlapping order of a circle.

[h2]isClickable

Method

public boolean isClickable()

Checks whether a circle is clickable.

Returns

Type

Description

boolean

true if a circle is clickable; false otherwise.

[h2]isVisible

Method

public boolean isVisible()

Checks whether a circle is visible.

Returns

Type

Description

boolean

true if a circle is visible; false otherwise.

[h2]remove

Method

public void remove()

Removes a circle from a map. After the circle is removed, the behavior of its methods is invalid.

[h2]setAnimation

Method

public void setAnimation(Animation animation)

Sets the animation for a circle.

NOTE:

Only TranslateAnimation is supported.

Parameters

Name

Description

Animation

Animation object.

[h2]setCenter

Method

public void setCenter(LatLng center)

Sets the longitude and latitude of the center of a circle. The center cannot be null because there is no default value.

NOTE:

A circle can be drawn only when the latitude of the circle center is within the range from -85.051119 to 85.051119. If the latitude of the circle center is -85.051119 or 85.051119, a circle with a radius of 1 meter can be drawn.

Parameters

Name

Description

center

Center of a circle.

Throws

Name

Description

NullPointerException

If the passed center is null.

[h2]setClickable

Method

public void setClickable(boolean clickable)

Sets whether a circle is clickable.

Parameters

Name

Description

clickable

Indicates whether a circle is clickable.

  • true: yes
  • false: no

[h2]setFillColor

Method

public void setFillColor(int color)

Sets the fill color of a circle. If it is set as transparent (Color.TRANSPARENT), the circle will not be filled with a color.

Parameters

Name

Description

color

Color in ARGB format. By default, the fill color is transparent (0x00000000).

[h2]setRadius

Method

public void setRadius(double radius)

Sets the radius of a circle.

NOTE:

A circle can be drawn only when the latitude of the circle center is within the range from -85.051119 to 85.051119. If the latitude of the circle center is -85.051119 or 85.051119, a circle with a radius of 1 meter can be drawn.

Parameters

Name

Description

radius

Radius of a circle, in meters. The value must be greater than or equal to 0. The default value is 0.

[h2]setStrokeColor

Method

public void setStrokeColor(int color)

Sets the stroke color of a circle's outline. If it is set as transparent, no outline will be drawn for the circle.

Parameters

Name

Description

color

Color in ARGB format. By default, the stroke color is black (0xff000000).

[h2]setStrokePattern

Method

public void setStrokePattern(List<PatternItem> pattern)

Sets the stroke pattern of a circle's outline.

Parameters

Name

Description

pattern

PatternItem object set. The default value is null, indicating that the stroke is in the solid pattern.

[h2]setStrokeWidth

Method

public void setStrokeWidth(float width)

Sets the stroke width of a circle's outline.

Parameters

Name

Description

width

Stroke width of a circle's outline, in pixels. The value must be greater than or equal to 0. The default value is 10.

Throws

Name

Description

IllegalArgumentException

If the passed width is a negative number.

[h2]setTag

Method

public <T> void setTag(T tag)

Sets the tag attribute of a circle. The tag attribute can be any object. If null is passed, the tag attribute will be cleared. If you no longer use the tag attribute, call setTag(null) to clear it to prevent memory leakage from occurring on the app.

Parameters

Name

Description

tag

Tag of a circle.

[h2]setVisible

Method

public void setVisible(boolean visible)

Sets whether a circle is visible. If the circle is invisible, it will not be drawn but all other states will be preserved. By default, a circle is visible.

Parameters

Name

Description

visible

Indicates whether a circle is visible.

  • true: yes
  • false: no

The default value is true.

[h2]setZIndex

Method

public void setZIndex(float zIndex)

Sets the z-index of a circle. The z-index indicates the overlapping order of a circle. A circle with a larger z-index overlaps that with a smaller z-index. Circles with the same z-index overlap each other by the order in which they are added. By default, the z-index is 0.

NOTE:

The following formula must be met: Number of circles and polygons x 2 + Number of polylines and ground overlays ≤ 1450. If the formula is not met, overlapping errors may occur.

Parameters

Name

Description

zIndex

Z-index, which indicates the overlapping order of a circle. The default value is 0.

[h2]startAnimation

Method

public void startAnimation()

Starts the animation.