Class: RegularShape

ol/style/RegularShape~RegularShape


import RegularShape from 'ol/style/RegularShape';

Set regular shape style for vector features. The resulting shape will be a regular polygon when radius is provided, or a star when radius1 and radius2 are provided.

new RegularShape(options)

Name Type Description
options

Options.

Name Type Description
fill module:ol/style/Fill~Fill

Fill style.

points number

Number of points for stars and regular polygons. In case of a polygon, the number of points is the number of sides.

radius number

Radius of a regular polygon.

radius1 number

First radius of a star. Ignored if radius is set.

radius2 number

Second radius of a star.

angle number (defaults to 0)

Shape's angle in radians. A value of 0 will have one of the shape's point facing up.

displacement Array.<number> (defaults to [0,0])

Displacement of the shape

stroke module:ol/style/Stroke~Stroke

Stroke style.

rotation number (defaults to 0)

Rotation in radians (positive rotation clockwise).

rotateWithView boolean (defaults to false)

Whether to rotate the shape with the view.

scale number | module:ol/size~Size (defaults to 1)

Scale. Unless two dimensional scaling is required a better result may be obtained with appropriate settings for radius, radius1 and radius2.

Subclasses

Extends

Methods

Clones the style.

Returns:
The cloned style.

getAnchor(){Array.<number>}

Get the anchor point in pixels. The anchor determines the center point for the symbolizer.

Returns:
Anchor.

getAngle(){number}

Get the angle used in generating the shape.

Returns:
Shape's rotation in radians.

getDisplacement(){Array.<number>} inherited

Get the displacement of the shape

Returns:
Shape's center displacement

Get the fill style for the shape.

Returns:
Fill style.

getImage(pixelRatio){HTMLCanvasElement}

Get the image icon.

Name Type Description
pixelRatio number

Pixel ratio.

Returns:
Image or Canvas element.

getOpacity(){number} inherited

Get the symbolizer opacity.

Returns:
Opacity.

getOrigin(){Array.<number>}

Get the origin of the symbolizer.

Returns:
Origin.

getPoints(){number}

Get the number of points for generating the shape.

Returns:
Number of points for stars and regular polygons.

getRadius(){number}

Get the (primary) radius for the shape.

Returns:
Radius.

getRadius2(){number|undefined}

Get the secondary radius for the shape.

Returns:
Radius2.

getRotateWithView(){boolean} inherited

Determine whether the symbolizer rotates with the map.

Returns:
Rotate with map.

getRotation(){number} inherited

Get the symoblizer rotation.

Returns:
Rotation.

Get the symbolizer scale.

Returns:
Scale.

Get the size of the symbolizer (in pixels).

Returns:
Size.

Get the stroke style for the shape.

Returns:
Stroke style.

setOpacity(opacity) inherited

Set the opacity.

Name Type Description
opacity number

Opacity.

setRotateWithView(rotateWithView) inherited

Set whether to rotate the style with the view.

Name Type Description
rotateWithView boolean

Rotate with map.

setRotation(rotation) inherited

Set the rotation.

Name Type Description
rotation number

Rotation.

setScale(scale) inherited

Set the scale.

Name Type Description
scale number | module:ol/size~Size

Scale.