MapView
@objc
open class MapView : UIView
Use the MapView
object to display the map in the view hierarchy.
-
MapView init method.
Ensure that MapsDisplayService.apiKey is set before calling this method, or use the
public init(mapOptions: MapOptions)
initializer as follows:lazy var mapView: MapView = { let mapOptions = MapOptions(apiKey: "YOUR MAP KEY") let mapView = MapView(mapOptions: mapOptions) return mapView }()
Declaration
Swift
public convenience init()
-
MapView init method. Initializes the map with given
MapOptions
.If
MapsDisplayService.apiKey
was set before calling this method, it will be overwritten with the MapOptions apiKey.Declaration
Swift
@objc public init(mapOptions: MapOptions)
Parameters
mapOptions
The map options.
-
MapView init method.
Ensure that MapsDisplayService.apiKey is set before calling this method, or use the
public init(mapOptions: MapOptions)
initializer as follows:lazy var mapView: MapView = { let mapOptions = MapOptions(apiKey: "YOUR MAP KEY") let mapView = MapView(mapOptions: mapOptions) return mapView }()
Declaration
Swift
override public convenience init(frame: CGRect)
Parameters
frame
The view frame.
-
MapView init with coder method.
If you are using xib or storyboards, ensure that make sure that MapsDisplayService.apiKey is set before loading MapView.
Declaration
Swift
public required init?(coder: NSCoder)
Parameters
coder
The coder object used to decode the
UIView
-
Forces the rendering view to redraw when the constraints-based layout is applied.
Declaration
Swift
override open func layoutSubviews()
-
The
MapViewDelegate
protocol that informs you whenMapView
is ready to be used.Declaration
Swift
public weak var delegate: MapViewDelegate?
-
Map management object.
Declaration
Swift
public private(set) lazy var map: TomTomMap { get set }
-
Tells the closure that the specified map view is ready to be used.
Declaration
Swift
public var onMapReadyCallback: ((TomTomMap) -> ())?
-
Notifies when new frame is rendered as a texture. When set, rendering performance may drop.
Important
Frame capture is supported only when using Metal renderer.Declaration
Swift
public weak var rendererFrameCaptureDelegate: MapRendererFrameCaptureDelegate? { get set }
-
Object for setting the map camera. Use it to set parameters such as:
- Position
- Zoom
- Tilt
- Rotation
Can be used with
UIView.animated
.
Example:
UIView.animate(withDuration: 5, delay: 2, options: [.beginFromCurrentState, .allowUserInteraction, .curveEaseIn], animations: { self.mapView.cameraUpdate = CameraUpdate(rotation: 180.0) }) { _ in }
}
Declaration
Swift
public var cameraUpdate: CameraUpdate { get set }
-
Preferred frames per second. Default value: 60 fps.
Declaration
Swift
public var preferredFramesPerSecond: Int { get set }
-
Sets scale view unit system. Default is auto which means it follows system settings.
Important
This is a Public Preview API. It may be changed or removed at any time.Declaration
Swift
public var scaleViewUnitSystem: UnitsSystem { get set }
-
This property sets the edge insets.
Declaration
Swift
public var contentInsets: NSDirectionalEdgeInsets { get set }
-
Replaces the list of data providers used as an alternative tile source. Tiles from the old data providers are loaded through the new data providers. If no data provider loads, the default data provider is used internally.
Important
This is a Public Preview API. It may be changed or removed at any time.Declaration
Swift
public func replaceDataProviders(_ dataProviders: [MapDisplayDataProvider])
Parameters
dataProviders
The data providers that are alternative tile sources.
-
The layout guide that represents the portion of the map view obscured by map scale.
Important
This is a Public Preview API. It may be changed or removed at any time.Declaration
Swift
public var mapButtonsBottomSafeAreaLayoutGuide: UILayoutGuide { get }
-
A Boolean value that determines whether the view is hidden.
Declaration
Swift
override public var isHidden: Bool { get set }
-
Sets a closure that will be triggered when the map instance is ready to use. The closure will be executed on the main thread.
Declaration
Swift
public func getMapAsync(closure: @escaping (TomTomMap) -> ())
Parameters
closure
The closure which handles the result.
-
Tells the view that its window object changed.
Declaration
Swift
override public func didMoveToWindow()
-
Tells the view that its superview changed.
Declaration
Swift
override public func didMoveToSuperview()
-
Sets the scale view visibility on the map.
Declaration
Swift
public var isScaleViewVisible: Bool { get set }
-
Sets the logo view visibility on the map.
Declaration
Swift
public var isLogoVisible: Bool { get set }
-
Compass button visibility policy.
See moreDeclaration
Swift
public enum CompassButtonVisibilityPolicy
-
Sets the control compass button visibility on the map. Default value:
.visibleWhenNeeded
Declaration
Swift
public var compassButtonVisibilityPolicy: CompassButtonVisibilityPolicy { get set }
-
Current location button visibility policy.
See moreDeclaration
Swift
public enum CurrentLocationButtonVisibilityPolicy
-
Sets the control current location visibility on the map. Default value:
.hiddenWhenCentered
Declaration
Swift
public var currentLocationButtonVisibilityPolicy: CurrentLocationButtonVisibilityPolicy { get set }
-
Whether the current location button is visible at the moment.
Declaration
Swift
public var isCurrentLocationButtonVisible: Bool { get }