Skip to main content

Class: SVGController

Defined in: controllers/SVGController.ts:28

Controller for managing the drawing of SVG shapes

Constructors

Constructor

new SVGController(container, initialViewport, options?): SVGController

Defined in: controllers/SVGController.ts:66

Parameters

container

SVGSVGElement

The <svg> element to draw on (typically created by createContainer)

initialViewport

Rect

Initial world-space viewport rectangle

options?

Optional shape drawing event handlers

onShapeComplete?

(shape) => void

Returns

SVGController

Properties

container

readonly container: SVGSVGElement

Defined in: controllers/SVGController.ts:29


shapeCompleteHandler?

readonly optional shapeCompleteHandler?: (shape) => void

Defined in: controllers/SVGController.ts:31

Parameters

shape

MultiPolygon

Returns

void


transformNode

readonly transformNode: SVGGElement

Defined in: controllers/SVGController.ts:30

Methods

destroy()

destroy(): void

Defined in: controllers/SVGController.ts:142

Returns

void


resizeContainer()

resizeContainer(newContainerSize): boolean

Defined in: controllers/SVGController.ts:118

Resizes the SVG container to match the given screen-space dimensions, accounting for devicePixelRatio

Parameters

newContainerSize

Desired container size in screen-space pixels

height

number

width

number

Returns

boolean

true if the container size actually changed, false otherwise


setInteractionMode()

setInteractionMode(newInteractionMode): void

Defined in: controllers/SVGController.ts:107

Updates the interaction mode

Parameters

newInteractionMode

InteractionMode

New interaction mode

Returns

void


setViewport()

setViewport(newViewport): boolean

Defined in: controllers/SVGController.ts:88

Updates the world-space viewport rectangle

Parameters

newViewport

Rect

New viewport bounds in world coordinates

Returns

boolean

true if the viewport actually changed, false otherwise


createContainer()

static createContainer(): SVGSVGElement

Defined in: controllers/SVGController.ts:51

Creates a positioned, full-size <svg> element for the SVG overlay

Returns

SVGSVGElement