MapView
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(mapKey: "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 mapKey.Declaration
Swift
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(mapKey: "YOUR MAP KEY") let mapView = MapView(mapOptions: mapOptions) return mapView }()
Declaration
Swift
override public 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)
-
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 mapReady: ((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.
Declaration
Swift
public var scaleViewUnitSystem: UnitsSystem { get set }
-
This property sets the edge insets.
Declaration
Swift
public var contentInsets: NSDirectionalEdgeInsets { get set }
-
The current application lifecycle monitor. Lifecycle monitor makes
mapView
aware of user application state. The default value isApplicationLifecycleMonitor
.Declaration
Swift
public var appLifecycleMonitor: ApplicationLifecycleMonitoring { get set }
-
The layout guide that represents the portion of the map view obscured by map scale.
Declaration
Swift
public var mapButtonsBottomSafeAreaLayoutGuide: UILayoutGuide { get }
-
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.
-
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 }