CameraManager

public class CameraManager

Undocumented

  • Creates a new Camera object to fit a given array of coordinates.

    Note: This method does not set the map’s camera to the new values. You must call setCamera in order for the changes to take effect.

    Declaration

    Swift

    public func camera(for coordinates: [CLLocationCoordinate2D]) -> CameraOptions

    Parameters

    array

    Array of coordinates that should fit within the new viewport.

    Return Value

    A Camera object that contains all coordinates within the viewport.

  • Returns the camera that best fits the given coordinate bounds, with optional edge padding, bearing, and pitch values.

    Declaration

    Swift

    public func camera(for coordinateBounds: CoordinateBounds,
                       edgePadding: UIEdgeInsets = UIEdgeInsets.zero,
                       bearing: CGFloat = 0.0,
                       pitch: CGFloat = 0.0) -> CameraOptions

    Parameters

    coordinateBounds

    The coordinate bounds that will be displayed within the viewport.

    edgePadding

    The new padding to be used by the camera. By default, this value is UIEdgeInsets.zero.

    bearing

    The new bearing to be used by the camera. By default, this value is 0.

    pitch

    The new pitch to be used by the camera. By default, this value is 0.

  • Returns the camera that best fits the given geometry, with optional edge padding, bearing, and pitch values.

    Declaration

    Swift

    public func camera(fitting geometry: Geometry,
                       edgePadding: UIEdgeInsets = UIEdgeInsets.zero,
                       bearing: CGFloat = 0.0,
                       pitch: CGFloat = 0.0) -> CameraOptions

    Parameters

    geometry

    The geoemtry that will be displayed within the viewport.

    edgePadding

    The new padding to be used by the camera. By default, this value is UIEdgeInsets.zero.

    bearing

    The new bearing to be used by the camera. By default, this value is 0.

    pitch

    The new pitch to be used by the camera. By default, this value is 0.

  • Returns the coordinate bounds for a given Camera object’s viewport.

    Declaration

    Swift

    public func coordinateBounds(for camera: CameraOptions) -> CoordinateBounds

    Parameters

    camera

    The camera that the coordinate bounds will be returned for.

  • Transition the camera view to a new map camera, optionally animating the change and executing a completion block after the transition occurs.

    Declaration

    Swift

    public func setCamera(to newCamera: CameraOptions,
                             animated: Bool = false,
                             duration: TimeInterval? = 0,
                             completion: ((Bool) -> Void)? = nil)

    Parameters

    newCamera

    The new map camera the viewport will transition to.

    animated

    A boolean indicating if the change should be animated. By default, this value is false

    completion

    The completion block to execute after the transition has occurred.

  • Transition the camera view to a new map camera based on individual camera properties, optionally animating the change and executing a completion block after the transition occurs.

    Declaration

    Swift

    public func setCamera(centerCoordinate: CLLocationCoordinate2D? = nil,
                          padding: UIEdgeInsets? = nil,
                          anchor: CGPoint? = nil,
                          zoom: CGFloat? = nil,
                          bearing: CLLocationDirection? = nil,
                          pitch: CGFloat? = nil,
                          animated: Bool = false,
                          duration: TimeInterval? = nil,
                          completion: ((Bool) -> Void)? = nil)

    Parameters

    center

    The new center coordinate the viewport will transition to.

    padding

    The new edge insets the viewport will use to to apply padding.

    anchor

    The new anchor point the viewport will use.

    zoom

    The new zoom level the viewport will transition to.

    bearing

    The bearing the viewport will rotate to.

    pitch

    The new pitch the viewport will transition to.

    animated

    A boolean indicating if the change should be animated. By default, this value is false

    completion

    The completion block to execute after the transition has occurred.

  • Undocumented

    Declaration

    Swift

    public func cancelTransitions()
  • Reset the map’s camera to the default style camera.

    Declaration

    Swift

    public func resetPosition()
  • Resets the map rotation to a north bearing of 0 degrees.

    Declaration

    Swift

    public func resetNorth(_ animated: Bool = false)

    Parameters

    animated

    A boolean indicating if the change should be animated. By default, this value is false.

  • Transitions the viewport to fit a given set of new coordinate bounds, optionally animating the change.

    This method also accounts for any UIEdgeInsets that may have been set through the the CameraView‘s padding property.

    Declaration

    Swift

    public func transitionCoordinateBounds(newCoordinateBounds: CoordinateBounds,
                                           animated: Bool = false)

    Parameters

    newCoordinateBounds

    The coordinate bounds that will be displayed within the viewport.

    animated

    A boolean indicating if the change should be animated. Defaults to false.

  • Transitions the viewport to fit a given set of new coordinate bounds, specifying a custom edge padding, an optional animation change, and an optional completion block to execute after the transition occurs.

    Declaration

    Swift

    public func transitionCoordinateBounds(to newCoordinateBounds: CoordinateBounds,
                                           edgePadding: UIEdgeInsets,
                                           animated: Bool = false,
                                           completion: (() -> Void)?)

    Parameters

    newCoordinateBounds

    The new coordinate bounds that will be displayed within the viewport.

    edgePadding

    The padding the viewport will adjust itself by after transitioning to the new viewport.

    animated

    A boolean indicating if the change should be animated. Defaults to false.

    completion

    An optional function to execute after the transition has occurred.

  • Transitions the viewport to fit a given array of new coordinates, specifying a custom edge padding an optional animation change.

    Declaration

    Swift

    public func transitionVisibleCoordinates(newCoordinates: [CLLocationCoordinate2D],
                                             edgePadding: UIEdgeInsets,
                                             animated: Bool = false)

    Parameters

    newCoordinates

    The coordinate bounds that will be displayed within the viewport.

    edgePadding

    The padding the viewport will adjust itself by after transitioning to the new viewport.

    animated

    A boolean indicating if the change should be animated. Defaults to false.

  • Transitions the viewport to fit a given array of new coordinates, specifying a custom edge padding, an optional animation change, and an optional completion block to execute after the transition occurs.

    Declaration

    Swift

    public func transitionVisibleCoordinates(to newCoordinates: [CLLocationCoordinate2D],
                                             edgePadding: UIEdgeInsets,
                                             bearing: CLLocationDirection,
                                             duration: TimeInterval,
                                             animated: Bool = false,
                                             completion: (() -> Void)?)

    Parameters

    newCoordinates

    The array of coordinates that will be displayed within the viewport.

    edgePadding

    The padding the viewport will adjust itself by after transitioning to the new viewport.

    animated

    A boolean indicating if the change should be animated. Defaults to false.

    completion

    An optional function to execute after the transition has occurred.

  • Moves the camera by given values with an optional animation.

    Declaration

    Swift

    public func moveCamera(by offset: CGPoint? = nil, rotation: CGFloat? = nil, pitch: CGFloat? = nil, zoom: CGFloat? = nil, animated: Bool = false)

    Parameters

    offset

    The CGPoint value to shift the map’s center by.

    rotation

    The angle to rotate the camera by.

    pitch

    The degrees to adjust the map’s tilt by.

    zoom

    The amount to adjust the camera’s zoom level by.

    animated

    Indicates whether the camera changes should be animated.

  • Moves the viewpoint to a different location using a transition animation that evokes powered flight and an optional transition duration and timing function

    The transition animation seamlessly incorporates zooming and panning to help the user find his or her bearings even after traversing a great distance.

    Declaration

    Swift

    public func fly(to camera: CameraOptions, duration: TimeInterval? = nil, timingFunction: CAMediaTimingFunction = CAMediaTimingFunction(name: .easeOut), completion: ((Bool) -> Void)? = nil)

    Parameters

    camera

    The camera at the end of the animation. Any camera parameters that are nil will not be animated.

    duration

    Duration of the animation, measured in seconds. If nil, a suitable calculated duration is used.

    timingFunction

    Timing function, defaults to “ease out”

    completion

    Completion handler called when the animation stops