MapView

@objc
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(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)

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

    Declaration

    Swift

    public func replaceDataProviders(_ dataProviders: [MapDisplayDataProvider])

    Parameters

    dataProviders

    The data providers that are alternative tile sources. Important: This is a Public Preview API. It may be changed or removed at any time.

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

View Lifecycle