MapOptions
public class MapOptions : NSObject
Allows the user to configure the initial parameters of the map.
MapOptions
is used in conjunction with MapView
initialization, 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. TheStyleContainer
usually contains 2StyleDefinition
s 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.defaultStyle
orStyleContainer.drivingStyle
. If noStyleContainer
is provided, the defaultStyleContainer.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 noStyleMode
is provided, the defaultStyleMode.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, onlineCachePolicy: OnlineCachePolicy = .default, cachePolicy: OnDiskCachePolicy = .default, styleMode: StyleMode? = nil, dataProviders: [MapDisplayDataProvider]? = nil )
Parameters
mapStyle
Provides an initial
StyleContainer
to define what style will the map use. TheStyleContainer
usually contains 2StyleDefinition
s 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.defaultStyle
orStyleContainer.drivingStyle
. If noStyleContainer
is provided, the defaultStyleContainer.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 theStyleContainer
does not contain a dark mode style, setting the map to dark mode will have no effect. If noStyleMode
is provided, the defaultStyleMode.main
will be used. Notice:StyleContainer.satelliteStyle
does not support dark mode.dataProviders
Custom
MapDisplayDataProvider
s 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. TheStyleContainer
usually contains 2StyleDefinition
s 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 noStyleContainer
is provided, the defaultStyleContainer.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 an initial
StyleMode
to use during map initialization, a style mode is either a main or dark mode of the map. If theStyleContainer
does not contain a dark mode style, setting the map to dark mode will have no effect. If noStyleMode
is provided, the defaultStyleMode.main
will be used. Notice:StyleContainer.satelliteStyle
does not support dark mode.Declaration
Swift
public let styleMode: StyleMode?
-
Custom
MapDisplayDataProvider
s 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]?