MTConfig

public actor MTConfig

Object representing the SDK global settings.

Exposes properties and options such as API Key and caching preferences.

  • Undocumented

    Declaration

    Swift

    public static let shared: MTConfig
  • SDK version

    Declaration

    Swift

    public static let version: String
  • SDK log level.

    Declaration

    Swift

    public private(set) var logLevel: MTLogLevel { get }
  • Boolean indicating whether caching is enabled.

    Note

    Defaults to true.

    Declaration

    Swift

    public private(set) var isCachingEnabled: Bool { get }
  • Boolean indicating whether session logic is enabled.

    This allows MapTiler to enable “session based billing”.

    Note

    Defaults to true.

    See also

    https://docs.maptiler.com/guides/maps-apis/maps-platform/what-is-map-session-in-maptiler-cloud/

    Declaration

    Swift

    public private(set) var isSessionLogicEnabled: Bool { get }
  • Boolean indicating whether telemetry is enabled.

    The telemetry is very valuable to the team at MapTiler because it shares information about where to add the extra effort. It also helps spotting some incompatibility issues that may arise between the SDK and a specific version of a module. It consist in sending the SDK version, API Key, MapTiler session ID, if tile caching is enabled, if language specified at initialization, if terrain is activated at initialization, if globe projection is activated at initialization.

    Note

    Defaults to true.

    Declaration

    Swift

    public private(set) var isTelemetryEnabled: Bool { get }
  • Sets the SDK log level.

    Declaration

    Swift

    public func setLogLevel(_ level: MTLogLevel)

    Parameters

    level

    The desired SDK log level.

  • Sets the MapTiler API key.

    Declaration

    Swift

    public func setAPIKey(_ apiKey: String, for map: MTMapView? = nil)

    Parameters

    apiKey

    The MapTiler API Key.

    map

    Map view to apply to.

  • Returns the MapTiler API key.

    Declaration

    Swift

    public func getAPIKey() -> String?
  • Returns the current MapTiler session ID.

    Declaration

    Swift

    public func getMaptilerSessionId() -> String?
  • Sets the caching mechanism.

    Note

    Enabled by default

    Declaration

    Swift

    public func setCaching(_ isEnabled: Bool, for map: MTMapView)

    Parameters

    isEnabled

    Boolean indicating whether caching is enabled.

    map

    Map view to apply to.

  • Sets the session logic.

    Make sure to call before map init or use MTMapOptions to supply before map init.

    Note

    Enabled by default

    See also

    https://docs.maptiler.com/guides/maps-apis/maps-platform/what-is-map-session-in-maptiler-cloud/

    Declaration

    Swift

    public func setSessionLogic(_ isEnabled: Bool, for map: MTMapView)

    Parameters

    isEnabled

    Boolean indicating whether session logic is enabled.

    map

    Map view to apply to.

  • Sets the unit of measurement.

    Note

    Default: .metric

    Declaration

    Swift

    public func setUnit(_ unit: MTUnit, for map: MTMapView)

    Parameters

    unit

    The MTUnit type.

    map

    Map view to apply to.

  • Returns the unit of measurement.

    Declaration

    Swift

    public func getUnit() -> MTUnit?
  • Sets the maximum number of tiles allowed for a single offline region download. This prevents users from accidentally downloading massive areas that consume too much storage. Note: MapTiler enforces an internal safety limit (currently 15,000 tiles). If you provide a value higher than the internal limit, the internal limit will be enforced.

    Declaration

    Swift

    public func setOfflineMaxTileCount(_ maxTileCount: Int)

    Parameters

    maxTileCount

    The maximum allowed tiles (default is 15,000).

  • Sets the telemetry.

    Note

    Enabled by default

    Declaration

    Swift

    public func setTelemetry(_ isEnabled: Bool, for map: MTMapView)

    Parameters

    isEnabled

    Boolean indicating whether telemetry is enabled.

    map

    Map view to apply to.

  • Handles events for the background URLSession. Call this from your AppDelegate’s application(_:handleEventsForBackgroundURLSession:completionHandler:)

    Declaration

    Swift

    public static func handleEventsForBackgroundURLSession(
        identifier: String,
        completionHandler: @escaping () -> Void
    )

    Parameters

    identifier

    The identifier of the URLSession.

    completionHandler

    The completion handler provided by the app delegate.