ViewAnnotationManager

public final class ViewAnnotationManager

Manager API to control View Annotations.

View annotations are UIView instances that are drawn on top of the MapView and bound to an arbitrary Geometry such as Point, or a Feature rendered on a layer. In case some view annotations intersect on the screen Z-index is based on addition order.

View annotations are invariant to map camera transformations however such properties as size, visibility etc could be controlled by the user using update operation.

  • If the superview or the UIView.isHidden property of a custom view annotation is changed manually by the users the SDK prints a warning and reverts the changes, as the view is still considered for layout calculation. The default value is true, and setting this value to false will disable the validation.

    Declaration

    Swift

    @available(*, deprecated)
    public var validatesViews: Bool { get set }
  • The complete list of annotations associated with the receiver.

    Declaration

    Swift

    @available(*, deprecated, message: "Use ViewAnnotation")
    public var annotations: [UIView : ViewAnnotationOptions] { get }
  • Add a ViewAnnotation to the map.

    To remove the annotation use remove() method.

    Declaration

    Swift

    public func add(_ annotation: ViewAnnotation)
  • Add a UIView instance which will be displayed as an annotation. View dimensions will be taken as width / height from the bounds of the view unless they are not specified explicitly with ViewAnnotationOptions and ViewAnnotationOptions.

    Annotation options must include Geometry where we want to bind our view annotation.

    Width and height could be specified explicitly but better idea will be not specifying them as they will be calculated automatically based on view layout.

    Important

    The annotation view to be added should have UIView.transform property set to .identity. Providing a transformed view can result in annotation views being misplaced, overlapped and other layout artifacts.

    Note

    Use update(_:options:) for changing the visibilty of the view, instead of UIView.isHidden so that it is removed from the layout calculation.

    Throws

    Throws:

    Declaration

    Swift

    @available(*, deprecated, message: "Use add(_:﹚ that takes ViewAnnotation")
    public func add(_ view: UIView, options: ViewAnnotationOptions) throws

    Parameters

    view

    UIView to be added to the map

    options

    ViewAnnotationOptions to control the layout and visibility of the annotation

  • Add a UIView instance which will be displayed as an annotation. View dimensions will be taken as width / height from the bounds of the view unless they are not specified explicitly with ViewAnnotationOptions and ViewAnnotationOptions.

    Annotation options must include Geometry where we want to bind our view annotation.

    Width and height could be specified explicitly but better idea will be not specifying them as they will be calculated automatically based on view layout.

    Important

    The annotation view to be added should have UIView.transform property set to .identity. Providing a transformed view can result in annotation views being misplaced, overlapped and other layout artifacts.

    Note

    Use update(_:options:) for changing the visibilty of the view, instead of UIView.isHidden so that it is removed from the layout calculation.

    Throws

    Throws:

    Declaration

    Swift

    @available(*, deprecated, message: "Use add(_:﹚ that takes ViewAnnotation")
    public func add(_ view: UIView, id: String?, options: ViewAnnotationOptions) throws

    Parameters

    view

    UIView to be added to the map

    id

    The unique string for the view.

    options

    ViewAnnotationOptions to control the layout and visibility of the annotation

  • Remove given UIView from the map if it was present.

    Declaration

    Swift

    @available(*, deprecated, message: "Use ViewAnnotation.remove(﹚")
    public func remove(_ view: UIView)

    Parameters

    view

    UIView to be removed

  • Removes all annotations views from the map.

    Declaration

    Swift

    public func removeAll()
  • Update given UIView with ViewAnnotationOptions. Important thing to keep in mind that only properties present in options will be updated, all other will remain the same as specified before.

    Important

    The annotation view to be updated should have UIView.frame property set to identify. Providing a transformed view can result in annotation views being misplaced, overlapped and other layout artifacts.

    Throws

    Declaration

    Swift

    @available(*, deprecated, message: "Use ViewAnnotation properties")
    public func update(_ view: UIView, options: ViewAnnotationOptions) throws

    Parameters

    view

    UIView to be updated

    options

    view annotation options with optional fields used for the update

  • Find view annotation by the given id.

    Declaration

    Swift

    @available(*, deprecated, message: "Use ViewAnnotation.view")
    public func view(forId id: String) -> UIView?

    Parameters

    id

    The identifier of the view set in add(_:id:options:).

    Return Value

    UIView if view was found, otherwise nil.

  • Get current ViewAnnotationOptions for given UIView.

    Declaration

    Swift

    @available(*, deprecated, message: "Use ViewAnnotation properties")
    public func options(for view: UIView) -> ViewAnnotationOptions?

    Parameters

    view

    an UIView for which the associated ViewAnnotationOptions is looked up

    Return Value

    ViewAnnotationOptions if view was found and nil otherwise.

  • Add an observer for annotation views updates

    Observers are held strongly.

    Declaration

    Swift

    @available(*, deprecated, message: "Use ViewAnnotation")
    public func addViewAnnotationUpdateObserver(_ observer: ViewAnnotationUpdateObserver)

    Parameters

    observer

    The object to notify when updates occur.

  • Remove an observer for annotation views updates.

    Declaration

    Swift

    @available(*, deprecated, message: "Use ViewAnnotation")
    public func removeViewAnnotationUpdateObserver(_ observer: ViewAnnotationUpdateObserver)

    Parameters

    observer

    The object to stop sending notifications to.

  • Calculates CameraOptions to fit the list of view annotations.

    Important

    This API isn’t supported by Globe projection.

    Important

    This method works only for annotations bound to point geometry. All other annotation will be ignored.

    If an annotation has multiple variableAnchors, the last picked anchor configuration will we used for bounding box calculation. If annotation is not yet rendered, the first first confit from the list will be used.

    Declaration

    Swift

    public func camera(
        forAnnotations annotations: [ViewAnnotation],
        padding: UIEdgeInsets = .zero,
        bearing: CGFloat? = nil,
        pitch: CGFloat? = nil
    ) -> CameraOptions?

    Parameters

    ids

    The list of annotations ids to be framed.

    padding
    bearing
    pitch
  • Calculates CameraOptions to fit the list of view annotations.

    Important

    This API isn’t supported by Globe projection.

    Declaration

    Swift

    @available(*, deprecated, message: "Use camera(forAnnotations:...﹚ that works with array of ViewAnnotation")
    public func camera(
        forAnnotations identifiers: [String],
        padding: UIEdgeInsets = .zero,
        bearing: CGFloat? = nil,
        pitch: CGFloat? = nil
    ) -> CameraOptions?

    Parameters

    ids

    The list of annotations ids to be framed.

    padding
    bearing
    pitch