MapView

open class MapView : UIView

Use the MapView object to display the map in the view hierarchy.

Lifecycle

  • 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)

Public

  • The MapViewDelegate protocol that informs you when MapView is ready to be used.

    Declaration

    Swift

    public weak var delegate: MapViewDelegate?
  • map

    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 is ApplicationLifecycleMonitor.

    Declaration

    Swift

    public var appLifecycleMonitor: ApplicationLifecycleMonitoring { get set }

Here should be a proper feature flag

  • The layout guide that represents the portion of the map view obscured by map scale.

    Declaration

    Swift

    public var mapButtonsBottomSafeAreaLayoutGuide: UILayoutGuide { get }