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
mapStyleProvides an initial
StyleContainerto define what style will the map use. TheStyleContainerusually contains 2StyleDefinitions 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 asStyleContainer.defaultStyleorStyleContainer.drivingStyle. If noStyleContaineris provided, the defaultStyleContainer.defaultStylewill be used.apiKeyThe API Key used for the map initialization.
cameraUpdateProvides an initial
CameraUpdatewhere 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)onlineCachePolicyProvides a custom
OnlineCachePolicyto use for tile caching, if no policy is provided the map will use the default policy for tile caching:memoryCapacity: 5MBdiskCapacity: 50MBcacheDurationFilter: [:]cachePolicyProvides a custom
OnDiskCachePolicyto use for style caching, if no policy is provided the map will use the default policy for style caching:duration: 24 hoursmaxSize: 100MBstyleModeProvides an initial
StyleModeto 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 noStyleModeis provided, the defaultStyleMode.mainwill be used. Notice:StyleContainer.satelliteStyledoes 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
mapStyleProvides an initial
StyleContainerto define what style will the map use. TheStyleContainerusually contains 2StyleDefinitions 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 asStyleContainer.defaultStyleorStyleContainer.drivingStyle. If noStyleContaineris provided, the defaultStyleContainer.defaultStylewill be used.apiKeyThe API Key used for the map initialization.
cameraUpdateProvides an initial
CameraUpdatewhere 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)cacheConfigurationProvides a custom
CacheConfigurationto use for tile and style caching, if no configuration is provided the map uses the default values for tile and style caching:memoryCapacity: 5MBdiskCapacity: 50MBduration: 24 hourscacheDurationFilter: [:]if cacheConfiguration isnil, it means the map will not cache tiles or styles.styleModeProvides an initial
StyleModeto 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 noStyleModeis provided, the defaultStyleMode.mainwill be used. Notice:StyleContainer.satelliteStyledoes 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
mapStyleProvides an initial
StyleContainerto define what style the map uses. TheStyleContainerusually contains twoStyleDefinitionobjects for each map style mode, dark and main. The map style can be a custom style or one of our pre-defined styles such asStyleContainer.defaultStyleorStyleContainer.drivingStyle. If noStyleContaineris provided, the defaultStyleContainer.defaultStyleis used.apiKeyThe API Key used for the map initialization.
cameraUpdateProvides an initial
CameraUpdatewhere 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)cacheConfigurationProvides a custom
CacheConfigurationto use for tile and style caching, if no configuration is provided the map will use the default values for tile and style caching:memoryCapacity: 5MBdiskCapacity: 50MBduration: 24 hourscacheDurationFilter: [:]if cacheConfiguration isnil, it means the map will not cache tiles or styles.styleModeProvides an initial
StyleModeto use during map initialization, a style mode is either a main or dark mode of the map. If theStyleContainerdoes not contain a dark mode style, setting the map to dark mode will have no effect. If noStyleModeis provided, the defaultStyleMode.mainwill be used. Notice:StyleContainer.satelliteStyledoes not support dark mode.dataProvidersCustom
MapDisplayDataProviders to provide the map’s tiles, for example,OfflineTileDataProviderfor the offline map.
-
Provides an initial
StyleContainerto define what style will the map use. TheStyleContainerusually contains 2StyleDefinitions 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.drivingStyleetc. If noStyleContaineris provided, the defaultStyleContainer.defaultStylewill 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
CameraUpdatewhere 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
OnDiskCachePolicyto use for style caching, if no policy is provided the map will use the default policy for style caching:duration: 24 hoursmaxSize: 100MBDeclaration
Swift
public let cachePolicy: OnDiskCachePolicy -
Provides a custom
OnlineCachePolicyto use for tile caching, if no policy is provided the map will use the default policy for tile caching:memoryCapacity: 5MBdiskCapacity: 50MBcacheDurationFilter: [:]Declaration
Swift
public let onlineCachePolicy: OnlineCachePolicy -
Provides a custom
CacheConfigurationto use for tile and style caching, if no policy is provided the map will use the default values for tile and style caching:memoryCapacity: 5MBdiskCapacity: 50MBduration: 24 hourscacheDurationFilter: [:]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
StyleModeto use during map initialization, a style mode is either a main or dark mode of the map. If theStyleContainerdoes not contain a dark mode style, setting the map to dark mode will have no effect. If noStyleModeis provided, the defaultStyleMode.mainwill be used. Notice:StyleContainer.satelliteStyledoes not support dark mode.Declaration
Swift
public let styleMode: StyleMode? -
Custom
MapDisplayDataProviders to provide the map’s tiles, for example,OfflineTileDataProviderfor 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]?
TomTom SDK for iOS (0.53.1)
MapOptions