BigJuJuMapViewController

@IBDesignable
@MainActor
open class BigJuJuMapViewController : UIViewController
extension BigJuJuMapViewController: MKMapViewDelegate
extension BigJuJuMapViewController: UIGestureRecognizerDelegate

This is the heart of this package.

It is a UIViewController, with a single, full-fill MKMapView. That view will have markers, designating the data provided.

Selecting a marker, will pop up a callout, with the data item name. If it is an aggregate annotation, then the callout will contain a list.

Selecting an item in the list, will trigger the callHandler() function, associated with that annotation, and the handler will be called (should be in the main thread, but that can be changed, by giving a threaded handler).

The map can display different markers, if ones are provided. Otherwise, it will use the default (simple “upside-down teardrop”) markers.

In the case of aggregate (multi) markers, the map can draw the number of contained data items, over the marker. This can be disabled.

Selecting a marker will display a simple “popover” over (or under) the selected marker. This will have a list of the data items associated with that marker.

Selecting an item will call a handler, with that item as its input argument.

Custom Annotation Class

  • This is used to denote a single annotation item

    See more

    Declaration

    Swift

    public class LocationAnnotation : NSObject, MKAnnotation

Custom Annotation View Class

  • This is used to display a map marker.

    See more

    Declaration

    Swift

    @MainActor
    public class AnnotationView : MKAnnotationView

PUBLIC PROPERTIES

  • Called the first time the map finishes rendering after it has been given its initial visible region.

    Declaration

    Swift

    @MainActor
    public var firstRenderDidComplete: (@MainActor @Sendable () -> Void)?
  • Called after the map’s visible rect has stabilized.

    Declaration

    Swift

    @MainActor
    public var visibleRectDidStabilize: (@MainActor @Sendable (MKMapRect) -> Void)?
  • The data for the map to display.

    Each item will be displayed in a marker. Markers may be aggregated.

    Declaration

    Swift

    @MainActor
    public var mapData: [any BigJuJuMapLocationProtocol] { get set }
  • The image to be used for markers, representing single locations. Default is the generic map marker (both single and aggregate)

    Declaration

    Swift

    @IBInspectable
    @MainActor
    public var singleMarkerImage: UIImage? { get set }
  • The image to be used for markers, representing aggregated locations. Default is the generic map marker (both single and aggregate)

    Declaration

    Swift

    @IBInspectable
    @MainActor
    public var multiMarkerImage: UIImage? { get set }
  • If true, multiple (aggregate) markers will display the number of elements aggregated. Default is true.

    Declaration

    Swift

    @IBInspectable
    @MainActor
    public var displayNumbers: Bool { get set }
  • If true (default is false), then popovers will not dismiss, when an item is selected.

    Declaration

    Swift

    @IBInspectable
    @MainActor
    public var stickyPopups: Bool

Public Computed Properties

  • The main view of this controller is a map. This simply casts that.

    Note

    This does an implicit unwrap, because we are in deep poo, if it fails.

    Declaration

    Swift

    @MainActor
    var mapView: MKMapView { get }
  • This allows direct access to the displayed map region.

    Declaration

    Swift

    @MainActor
    var region: MKCoordinateRegion { get set }
  • This allows direct access to the displayed map rect.

    Declaration

    Swift

    @MainActor
    var visibleRect: MKMapRect { get set }

Public Instance Methods

  • Called when the view hierarchy has completed loading, but before it is laid out and displayed.

    Declaration

    Swift

    @MainActor
    public override func viewDidLoad()

MKMapViewDelegate Conformance

  • Returns the appropriate marker view for an annotation.

    Declaration

    Swift

    @MainActor
    public func mapView(_ inMapView: MKMapView,
                        viewFor inAnnotation: any MKAnnotation
    ) -> MKAnnotationView?

    Parameters

    inMapView

    The map view the annotation is attached to.

    inAnnotation

    The annotation for the marker.

    Return Value

    A new annotation view instance.

  • Called when the map has finished rendering all its tiles. We use it to force the annotations to be recalculated.

    Declaration

    Swift

    @MainActor
    public func mapViewDidFinishRenderingMap(_ inMapView: MKMapView,
                                             fullyRendered: Bool
    )

    Parameters

    inMapView

    The map view being rendered (ignored).

    fullyRendered

    Ignored.

  • Called when the map has changed its region. We use it to force the annotations to be recalculated.

    Declaration

    Swift

    @MainActor
    public func mapView(_ inMapView: MKMapView,
                        regionDidChangeAnimated: Bool
    )

    Parameters

    inMapView

    The map view being rendered (ignored).

    regionDidChangeAnimated

    Ignored.

  • Called when the map is going to change its region.

    Declaration

    Swift

    @MainActor
    public func mapView(_ inMapView: MKMapView,
                        regionWillChangeAnimated: Bool
    )

    Parameters

    inMapView

    The map view being rendered (ignored).

    regionWillChangeAnimated

    Ignored.

  • This is called when a marker is selected.

    Declaration

    Swift

    @MainActor
    public func mapView(_ inMapView: MKMapView,
                        didSelect inView: MKAnnotationView
    )

    Parameters

    inMapView

    The map view

    inView

    The marker we’re selecting.

  • This is called when a marker is deselected.

    Declaration

    Swift

    @MainActor
    public func mapView(_ inMapView: MKMapView,
                        didDeselect inView: MKAnnotationView
    )

    Parameters

    inMapView

    The map view

    inView

    The marker we’re deselecting.

UIGestureRecognizerDelegate Conformance

  • Called to determine whether or not to consume a touch event.

    Declaration

    Swift

    @MainActor
    public func gestureRecognizer(_ inGestureRecognizer: UIGestureRecognizer,
                                  shouldReceive inTouch: UITouch
    ) -> Bool

    Parameters

    inGestureRecognizer

    The gesture recognizer(ignored)

    inTouch

    The touch event

    Return Value

    True, if the touch event is valid.