Skip to main content

Class: SVGController

Defined in: controllers/SVGController.ts:19

Controller for managing the drawing of SVG shapes

Constructors

Constructor

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

Defined in: controllers/SVGController.ts:55

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:20


shapeCompleteHandler?

readonly optional shapeCompleteHandler?: (shape) => void

Defined in: controllers/SVGController.ts:22

Parameters

shape

MultiPolygon

Returns

void


transformNode

readonly transformNode: SVGGElement

Defined in: controllers/SVGController.ts:21

Methods

destroy()

destroy(): void

Defined in: controllers/SVGController.ts:131

Returns

void


resizeContainer()

resizeContainer(newContainerSize): boolean

Defined in: controllers/SVGController.ts:107

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:96

Updates the interaction mode

Parameters

newInteractionMode

InteractionMode

New interaction mode

Returns

void


setViewport()

setViewport(newViewport): boolean

Defined in: controllers/SVGController.ts:77

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:40

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

Returns

SVGSVGElement