Home Manual Reference Source
protected class | source

ImageHandler

Image resource handler

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public get

Get api instance

public get

Resource url, can be used in an image tag

Method Summary

Public Methods
public

async delete()

Delete image

public

Download the image

public

async upload(image: ArrayBuffer | ArrayBufferView | File | Blob | Buffer)

Upload new image

Public Constructors

public constructor(api: Maps4News, target: ResourceBase) source

Params:

NameTypeAttributeDescription
api Maps4News

Api instance

target ResourceBase

Instance of target item

Public Members

public get api: Maps4News: * source

Get api instance

Return:

Maps4News

Api instance

public get url: string: string source

Resource url, can be used in an image tag

Return:

string

Resource url

Public Methods

public async delete() source

Delete image

Throw:

ApiError

public async download(): Promise<DownloadedResource> source

Download the image

Return:

Promise<DownloadedResource>

image

Example:

// Browser
layer.imageHandler.download().then(image => {
  $('img').src = image.createObjectURL();
});

// NodeJs
layer.imageHandler.download().then({fileName, data} => {
  fs.writeFileSync(fileName, data);
});

public async upload(image: ArrayBuffer | ArrayBufferView | File | Blob | Buffer) source

Upload new image

Params:

NameTypeAttributeDescription
image ArrayBuffer | ArrayBufferView | File | Blob | Buffer

Image file