Circle
AMap.Circle
Construct a circle object, specifying the circle style via CircleOptions
new AMap.Circle(opts: CircleOptions)Parameter
opts (CircleOptions): Circle parameters
Demo
var circle = new AMap.Circle({
center: new AMap.LngLat(100.491422, 13.749313),
radius: 1000,
borderWeight: 3,
strokeColor: "#FF33FF",
});
map.add(circle);Method
setCenter(center)
Set the center point of the circle
Parameter: center (LngLat) The center point of the circle, supports passing in a longitude and latitude object or a one-dimensional array of longitude and latitude, such as: AMap.LngLat(116.39,39.9) or [116.39, 39.9]
Demo:
circle.setCenter(new AMap.LngLat(100.491422, 13.749313));setRadius(radius)
Set the radius of the circle
Parameter: radius (number) Radius of the circle
Demo:
circle.setRadius(100);getCenter()
Get the center point of the circle
return value: (LngLat) Latitude and longitude information of the circle center
Demo:
circle.getCenter();getRadius()
Get the radius of the circle
return value: (number) Radius of the circle
Demo:
circle.getRadius();contains(point)
Determine if the specified point coordinates are inside the circle
Parameter: point (LngLatLike) Specified point coordinates
return value: (boolean) true (coordinates are inside the circle), false (coordinates are outside the circle)
Demo:
circle.contains(new AMap.LngLat(116.433322, 39.900255));setOptions(optsArg)
Modifying the properties of a circle (including the nodes that form the circular outline, the style of the outline, etc. For details on the properties, refer to the CircleOptions list) does not support changing the center position
Parameter: optsArg (CircleOptions) Properties of a Circle
Demo:
circle.setOptions({
borderWeight: 3,
strokeColor: "#FF33FF",
});hide()
Hide the circle
Demo:
circle.hide();setHeight(height)
Set the height above ground of the circular plane (This method and related property height are applicable to JSAPI v2.1Beta and above)
Parameter: height (Number) Height above ground of the circular plane
Demo:
circle.setHeight(0);getPlaneHeight()
Get the height above ground value of the circular plane (This method is applicable to JSAPI 2.1Beta and above)
return value: (Number) Height above ground of the circle's plane
Demo:
circle.getPlaneHeight();show()
Display circle
Demo:
circle.show();getExtData()
Get user-defined properties
return value: (Object) The value set by the extData property, returns an empty object if not set
Demo:
circle.getExtData();setExtData(extData)
Set user-defined properties, supporting any data type in JavaScript API
Parameter: extData (Object) User-defined data
Demo:
circle.setExtData({id:1});destroy()
Destroy Memory - Circle
Demo:
circle.destroy();getArea()
Get Area of a Circle, Unit: Square Meters
return value: (number) Area of a Circle
Demo:
circle.getArea();getOptions()
Get Properties of a Circle
return value: (CircleOptions) Properties of a Circle
Demo:
circle.getOptions();getPath()
Get Circular Contour Node Array
return value: (Array<LngLat> | Array<Array<LngLat>>) Return Path
Demo:
circle.getPath();Event
For event object property descriptions, go to:MapsEvent