MapOptions

public class MapOptions : NSObject

Allows the user to configure the initial parameters of the map.

MapOptions is used in conjunction with MapViewinitialization, i.e: When creating a MapView, it is possible to pass a MapOptions object to configure the MapView before it is showing on the screen, for example, creating a MapView object with the default TomTom style, and a dark style mode: let mapOptions = MapOptions(mapStyle: .defaultStyle, apiKey: "your-key", styleMode: .dark) let mapView = MapView(mapOptions: mapOptions)

Creating a MapView without passing a MapOptions object, will result in the MapView being created using the deafult values. In such case, the API Key that will be used for the map will be taken from MapsDisplayService.apiKey.

  • Creates an instance of MapOptions.

    Declaration

    Swift

    public init(
        mapStyle: StyleContainer? = nil,
        apiKey: String,
        cameraUpdate: CameraUpdate? = nil,
        onlineCachePolicy: OnlineCachePolicy = .default,
        cachePolicy: OnDiskCachePolicy = .default,
        styleMode: StyleMode? = nil
    )

    Parameters

    mapStyle

    Provides an initial StyleContainer to define what style will the map use. The StyleContainer usually contains 2 StyleDefinitions objects for each map style mode, dark and main. The map style can be a custom style or one of our pre-defined styles such as StyleContainer.defaultStyle or StyleContainer.drivingStyle. If no StyleContainer is provided, the default StyleContainer.defaultStyle will be used.

    apiKey

    The API Key used for the map initialization.

    cameraUpdate

    Provides an initial CameraUpdate where zoom, tilt, rotation and more camera properties can be defined. These values can be used to configure the initial camera state of the map. For example, setting the map camera to have a 10 zoom-level, 45 tilt, 30 rotation and 0.5 field of view. let cameraUpdate = CameraUpdate(zoom: 10, tilt: 45, rotation: 30, fieldOfView: 0.5) let mapOptions = MapOptions(apiKey: "your-key", cameraUpdate: cameraUpdate)

    onlineCachePolicy

    Provides a custom OnlineCachePolicy to use for tile caching, if no policy is provided the map will use the default policy for tile caching: memoryCapacity: 5MB diskCapacity: 50MB cacheDurationFilter: [:]

    cachePolicy

    Provides a custom OnDiskCachePolicy to use for style caching, if no policy is provided the map will use the default policy for style caching: duration: 24 hours maxSize: 100MB

    styleMode

    Provides an initial StyleMode to use during map initialization, a style mode is either a main or dark mode of the map. If the style does not contain dark mode, setting the map to dark mode will have no effect. If no StyleMode is provided, the default StyleMode.main will be used. Notice: StyleContainer.satelliteStyle does not support dark mode.

  • Creates an instance of MapOptions.

    Important

    This is a Public Preview API. It may be changed or removed at any time.

    Declaration

    Swift

    public init(
        mapStyle: StyleContainer? = nil,
        apiKey: String,
        cameraUpdate: CameraUpdate? = nil,
        cacheConfiguration: CacheConfiguration? = .init(),
        styleMode: StyleMode? = nil
    )

    Parameters

    mapStyle

    Provides an initial StyleContainer to define what style will the map use. The StyleContainer usually contains 2 StyleDefinitions objects for each map style mode, dark and main. The map style can be a custom style or one of our pre-defined styles such as StyleContainer.defaultStyle or StyleContainer.drivingStyle. If no StyleContainer is provided, the default StyleContainer.defaultStyle will be used.

    apiKey

    The API Key used for the map initialization.

    cameraUpdate

    Provides an initial CameraUpdate where zoom, tilt, rotation and more camera properties can be defined. These values can be used to configure the initial camera state of the map. For example, setting the map camera to have a 10 zoom-level, 45 tilt, 30 rotation and 0.5 field of view. let cameraUpdate = CameraUpdate(zoom: 10, tilt: 45, rotation: 30, fieldOfView: 0.5) let mapOptions = MapOptions(apiKey: "your-key", cameraUpdate: cameraUpdate)

    cacheConfiguration

    Provides a custom CacheConfiguration to use for tile and style caching, if no configuration is provided the map uses the default values for tile and style caching: memoryCapacity: 5MB diskCapacity: 50MB duration: 24 hours cacheDurationFilter: [:] if cacheConfiguration is nil, it means the map will not cache tiles or styles.

    styleMode

    Provides an initial StyleMode to use during map initialization, a style mode is either a main or dark mode of the map. If the style does not contain dark mode, setting the map to dark mode will have no effect. If no StyleMode is provided, the default StyleMode.main will be used. Notice: StyleContainer.satelliteStyle does not support dark mode.

  • Creates an instance of MapOptions.

    Important

    This is a Public Preview API. It may be changed or removed at any time.

    Declaration

    Swift

    public init(
        mapStyle: StyleContainer? = nil,
        apiKey: String,
        cameraUpdate: CameraUpdate? = nil,
        cacheConfiguration: CacheConfiguration? = .init(),
        styleMode: StyleMode? = nil,
        dataProviders: [MapDisplayDataProvider]? = nil
    )

    Parameters

    mapStyle

    Provides an initial StyleContainer to define what style the map uses. The StyleContainer usually contains two StyleDefinition objects for each map style mode, dark and main. The map style can be a custom style or one of our pre-defined styles such as StyleContainer.defaultStyle or StyleContainer.drivingStyle. If no StyleContainer is provided, the default StyleContainer.defaultStyle is used.

    apiKey

    The API Key used for the map initialization.

    cameraUpdate

    Provides an initial CameraUpdate where zoom, tilt, rotation and more camera properties can be defined. These values can be used to configure the initial camera state of the map. For example, setting the map camera to have a 10 zoom-level, 45 tilt, 30 rotation and 0.5 field of view. let cameraUpdate = CameraUpdate(zoom: 10, tilt: 45, rotation: 30, fieldOfView: 0.5) let mapOptions = MapOptions(apiKey: "your-key", cameraUpdate: cameraUpdate)

    cacheConfiguration

    Provides a custom CacheConfiguration to use for tile and style caching, if no configuration is provided the map will use the default values for tile and style caching: memoryCapacity: 5MB diskCapacity: 50MB duration: 24 hours cacheDurationFilter: [:] if cacheConfiguration is nil, it means the map will not cache tiles or styles.

    styleMode

    Provides an initial StyleMode to use during map initialization, a style mode is either a main or dark mode of the map. If the StyleContainer does not contain a dark mode style, setting the map to dark mode will have no effect. If no StyleMode is provided, the default StyleMode.main will be used. Notice: StyleContainer.satelliteStyle does not support dark mode.

    dataProviders

    Custom MapDisplayDataProviders to provide the map’s tiles, for example, OfflineTileDataProvider for the offline map.

  • Provides an initial StyleContainer to define what style will the map use. The StyleContainer usually contains 2 StyleDefinitions objects for each map style mode, dark and main. The map style can be a custom style or one of our pre-defined styles, i.e: StyleContainer.defaultStyle, StyleContainer.drivingStyle etc. If no StyleContainer is provided, the default StyleContainer.defaultStyle will be used.

    Declaration

    Swift

    public let mapStyle: StyleContainer?
  • The API Key used for the map initialization.

    Declaration

    Swift

    public let apiKey: String
  • Provides an initial CameraUpdate where zoom, tilt, rotation and more camera properties can be defined. These values can be used to configure the initial camera state of the map. For example, setting the map camera to have a 10 zoom-level, 45 tilt, 30 rotation and 0.5 field of view. let cameraUpdate = CameraUpdate(zoom: 10, tilt: 45, rotation: 30, fieldOfView: 0.5) let mapOptions = MapOptions(apiKey: "your-key", cameraUpdate: cameraUpdate)

    Declaration

    Swift

    public let cameraUpdate: CameraUpdate?
  • Provides a custom OnDiskCachePolicy to use for style caching, if no policy is provided the map will use the default policy for style caching: duration: 24 hours maxSize: 100MB

    Declaration

    Swift

    public let cachePolicy: OnDiskCachePolicy
  • Provides a custom OnlineCachePolicy to use for tile caching, if no policy is provided the map will use the default policy for tile caching: memoryCapacity: 5MB diskCapacity: 50MB cacheDurationFilter: [:]

    Declaration

    Swift

    public let onlineCachePolicy: OnlineCachePolicy
  • Provides a custom CacheConfiguration to use for tile and style caching, if no policy is provided the map will use the default values for tile and style caching: memoryCapacity: 5MB diskCapacity: 50MB duration: 24 hours cacheDurationFilter: [:]

    if cacheConfiguration is nil, it means the map will not cache tiles or styles.

    Important

    This is a Public Preview API. It may be changed or removed at any time.

    Declaration

    Swift

    public let cacheConfiguration: CacheConfiguration?
  • Provides an initial StyleMode to use during map initialization, a style mode is either a main or dark mode of the map. If the StyleContainer does not contain a dark mode style, setting the map to dark mode will have no effect. If no StyleMode is provided, the default StyleMode.main will be used. Notice: StyleContainer.satelliteStyle does not support dark mode.

    Declaration

    Swift

    public let styleMode: StyleMode?
  • Custom MapDisplayDataProviders to provide the map’s tiles, for example, OfflineTileDataProvider for the offline map.

    Important

    This is a Public Preview API. It may be changed or removed at any time.

    Declaration

    Swift

    public let dataProviders: [MapDisplayDataProvider]?