Skip to main content

Class: ViewBox

ViewBox class for managing the view box of the map. The view box is a rectangular area of the SVG canvas that is visible to the user. It is used to define the portion of the SVG canvas that is visible to the user.

Constructors

Constructor

new ViewBox(
x?,
y?,
width?,
height?): ViewBox;

Constructs a new ViewBox object.

Parameters

ParameterTypeDescription
x?| string | number | ViewBox | ViewBoxLiteral | ViewBoxArrayThe x-coordinate of the viewBox. Can be a number, a ViewBox object, a ViewBoxLiteral object, a ViewBoxArray, or a string in the format "x y width height".
y?string | numberThe y-coordinate of the viewBox. Can be a number or a string.
width?string | numberThe width of the viewBox. Can be a number or a string.
height?string | numberThe height of the viewBox. Can be a number or a string.

Returns

ViewBox

Methods

addPadding()

addPadding(padding): void;

Adds padding to the viewBox

Parameters

ParameterType
padding{ bottom: number; left: number; right: number; top: number; }
padding.bottomnumber
padding.leftnumber
padding.rightnumber
padding.topnumber

Returns

void


clone()

clone(): ViewBox;

Returns

ViewBox


fitsInViewBox()

fitsInViewBox(viewBox, atLeastByOneDimension?): boolean;

Check whether current viewBox fits inside of another viewBox

Parameters

ParameterType
viewBoxViewBox
atLeastByOneDimension?boolean

Returns

boolean


toArray()

toArray(): number[];

Returns an array containing viewBox numbers

Returns

number[]


toString()

toString(): string;

Returns a string with viewBox numbers

Returns

string


update()

update(
x,
y?,
width?,
height?): void;

Updates the viewBox with new coordinates and dimensions.

Parameters

ParameterType
x| string | number | ViewBox | ViewBoxLiteral | ViewBoxArray
y?string | number
width?string | number
height?string | number

Returns

void

Properties

height

height: number = 0;

initialized

initialized: boolean = false;

width

width: number = 0;

x

x: number = 0;

y

y: number = 0;