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 some Geometry (only Point is supported for now).
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.
View annotations are not explicitly bound to any sources however associatedFeatureId could be
used to bind given view annotation with some Feature by Feature.identifier meaning visibility of view annotation will be driven
by visibility of given feature.
-
If the superview or the
UIView.isHiddenproperty 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
public var validatesViews: Bool
-
Add a
UIViewinstance 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 withwidthandheight.Annotation
optionsmust 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.transformproperty 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 ofUIView.isHiddenso that it is removed from the layout calculation.Throws
Throws:
viewIsAlreadyAddedif the supplied view is already added as an annotationgeometryFieldMissingif options did not include geometryassociatedFeatureIdIsAlreadyInUseif the suppliedassociatedFeatureIdis already used by another annotation viewMapError: errors during insertion
Declaration
Swift
public func add(_ view: UIView, options: ViewAnnotationOptions) throwsParameters
viewUIViewto be added to the mapoptionsViewAnnotationOptionsto control the layout and visibility of the annotation -
Add a
UIViewinstance 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 withwidthandheight.Annotation
optionsmust 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.transformproperty 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 ofUIView.isHiddenso that it is removed from the layout calculation.Throws
Throws:
viewIsAlreadyAddedif the supplied view is already added as an annotation, or there is an existing annotation view with the sameid.geometryFieldMissingif options did not include geometryassociatedFeatureIdIsAlreadyInUseif the suppliedassociatedFeatureIdis already used by another annotation viewMapError: errors during insertion
Declaration
Swift
public func add(_ view: UIView, id: String?, options: ViewAnnotationOptions) throwsParameters
viewUIViewto be added to the mapidThe unique string for the
view.optionsViewAnnotationOptionsto control the layout and visibility of the annotation -
Remove given
UIViewfrom the map if it was present.Declaration
Swift
public func remove(_ view: UIView)Parameters
viewUIViewto be removed -
Removes all annotations views from the map.
Declaration
Swift
public func removeAll() -
Update given
UIViewwithViewAnnotationOptions. Important thing to keep in mind that only properties present inoptionswill be updated, all other will remain the same as specified before.Important
The annotation view to be updated should have
UIView.frameproperty set toidentify. Providing a transformed view can result in annotation views being misplaced, overlapped and other layout artifacts.Throws
annotationNotFound: the supplied view was not foundassociatedFeatureIdIsAlreadyInUseif the suppliedassociatedFeatureIdis already used by another annotation viewMapError: errors during the update of the view (eg. incorrect parameters)
Declaration
Swift
public func update(_ view: UIView, options: ViewAnnotationOptions) throwsParameters
viewUIViewto be updatedoptionsview annotation options with optional fields used for the update
-
Find view annotation by the given
id.Declaration
Swift
public func view(forId id: String) -> UIView?Parameters
idThe identifier of the view set in
add(_:id:options:).Return Value
UIViewif view was found, otherwisenil. -
Find
UIViewby feature id if it was specified as part ofassociatedFeatureId.Declaration
Swift
public func view(forFeatureId identifier: String) -> UIView?Parameters
identifierthe identifier of the feature which will be used for finding the associated
UIViewReturn Value
UIViewif view was found andnilotherwise. -
Find
ViewAnnotationOptionsof view annotation by feature id if it was specified as part ofassociatedFeatureId.Declaration
Swift
public func options(forFeatureId identifier: String) -> ViewAnnotationOptions?Parameters
identifierthe identifier of the feature which will be used for finding the associated
ViewAnnotationOptionsReturn Value
ViewAnnotationOptionsif view was found andnilotherwise. -
Get current
ViewAnnotationOptionsfor givenUIView.Declaration
Swift
public func options(for view: UIView) -> ViewAnnotationOptions?Parameters
viewan
UIViewfor which the associatedViewAnnotationOptionsis looked upReturn Value
ViewAnnotationOptionsif view was found andnilotherwise. -
Add an observer for annotation views updates
Observers are held strongly.
Declaration
Swift
public func addViewAnnotationUpdateObserver(_ observer: ViewAnnotationUpdateObserver)Parameters
observerThe object to notify when updates occur.
-
Remove an observer for annotation views updates.
Declaration
Swift
public func removeViewAnnotationUpdateObserver(_ observer: ViewAnnotationUpdateObserver)Parameters
observerThe object to stop sending notifications to.
ViewAnnotationManager Class Reference