Home > @magiclane/maps-sdk > GemImage

GemImage class

GemImage class representing an image with format and metadata

Signature:

export declare class GemImage 

Constructors

Constructor

Modifiers

Description

(constructor)({ image, format, imageId, }, input)

Constructor

SVG bytes are accepted anywhere an image is accepted: when the bytes look like an SVG document (or format is ImageFileFormat.svg), they are rasterized to PNG in the background at 2× the SVG's declared size. Because rasterization is asynchronous in browsers, either use the await-able GemImage.fromSvg() factory (recommended) or call await GemImage.whenSvgReady() before passing SVG-backed images to the engine (e.g. addList).

Properties

Property

Modifiers

Type

Description

aspectRatioX

number

Aspect ratio X

aspectRatioY

number

Aspect ratio Y

format?

ImageFileFormat

(Optional) Image format

image?

Uint8Array

(Optional) Image data

imageId

number

Image ID

Methods

Method

Modifiers

Description

equals(other)

Equality comparison

fromJson(json)

static

Create from JSON representation

fromSvg(svg)

static

Create a GemImage from SVG markup or SVG bytes. The SVG is rasterized to PNG (2× its declared size, so mm-scaled icons stay crisp on high-DPI screens) before the image is returned — the result can be handed to the engine like any PNG image.

hashCode()

Hash code calculation

toJson()

Convert to JSON representation

toJSON()

Standard JS hook invoked by JSON.stringify. Delegates to toJson so Uint8Array bytes serialize as a number array (EVarList on the C++ side) rather than the default object-with-string-keys form, which would be tagged as EVarMap and produce an empty vector.

whenReady()

Resolves once this image's pending SVG rasterization (if any) has finished. Immediate for non-SVG images.

whenSvgReady()

static

Resolves once every pending SVG rasterization started so far (by any GemImage) has finished. Call before addList/add when SVG images were built via new GemImage(...) instead of fromSvg.