Home > @magiclane/maps-sdk > MapDownloaderService > startDownload

MapDownloaderService.startDownload() method

Starts downloading map tiles for the specified geographic area(s).

Completion is reported through the onComplete callback with a GemError indicating the final status. If the operation cannot be started an error will be delivered to onComplete and the method returns null.

Signature:

startDownload(areas: RectangleGeographicArea[], onComplete: (err: GemError) => void): ProgressListener | null;

Parameters

Parameter

Type

Description

areas

RectangleGeographicArea[]

A list of one or more geographic rectangles to download tiles for

onComplete

(err: GemError) => void

Callback invoked when the operation finishes with a GemError

Returns:

ProgressListener | null

A ProgressListener instance that can be used to monitor progress, or null if the operation could not be started

Example

const service = new MapDownloaderService();
service.maxSquareKm = 300;

service.startDownload([area], (err) => {
  if (err === GemError.success) {
    console.log('Download started successfully.');
  } else {
    console.log('Failed to start download:', err);
  }
});