Getting started | Mobile SDK | 2GIS Documentation

Getting started

First you need to contact 2GIS technical support to get a new key. Be sure to specify the appId of the application for which the key will be generated.

To begin working with the SDK, create a Container object, which will store all map entities.

To create it, you need to specify path to your key file via ApiKeyOptions. When specifying ApiKeyOptions.default, the file must be added to the application root.

// Key file.
let apiKeyOptions = ApiKeyOptions(apiKeyFile: File(path: "Path to key info file"))

// Создание контейнера для доступа к возможностям SDK.
let sdk = DGis.Container(apiKeyOptions: apiKeyOptions)

Note that DGis.Container can be created in single instance.

Additionally, you can specify logging settings (LogOptions) and HTTP client settings (HTTPOptions) such as timeout and caching.

// Logging settings.
let logOptions = LogOptions(osLogLevel: .info)

// HTTP client settings.
let httpOptions = HTTPOptions.default

// Geopositioning settings.
let positioningServices: IPositioningServicesFactory = CustomPositioningServicesFactory()

// Consent to personal data processing.
let dataCollectionOptions = DataCollectionOptions(dataCollectionStatus: .agree)

// Creating the Container.
let sdk = DGis.Container(
	apiKeyOptions: apiKeyOptions,
	logOptions: logOptions,
	httpOptions: httpOptions,
	positioningServices: positioningServices,
	dataCollectionOptions: dataCollectionOptions