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.
-
This is used to denote a single annotation item
See moreDeclaration
Swift
public class LocationAnnotation : NSObject, MKAnnotation
-
This is used to display a map marker.
See moreDeclaration
Swift
@MainActor public class AnnotationView : MKAnnotationView
-
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
-
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 }
-
Called when the view hierarchy has completed loading, but before it is laid out and displayed.
Declaration
Swift
@MainActor public override func viewDidLoad()
-
Returns the appropriate marker view for an annotation.
Declaration
Swift
@MainActor public func mapView(_ inMapView: MKMapView, viewFor inAnnotation: any MKAnnotation ) -> MKAnnotationView?Parameters
inMapViewThe map view the annotation is attached to.
inAnnotationThe 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
inMapViewThe map view being rendered (ignored).
fullyRenderedIgnored.
-
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
inMapViewThe map view being rendered (ignored).
regionDidChangeAnimatedIgnored.
-
Called when the map is going to change its region.
Declaration
Swift
@MainActor public func mapView(_ inMapView: MKMapView, regionWillChangeAnimated: Bool )Parameters
inMapViewThe map view being rendered (ignored).
regionWillChangeAnimatedIgnored.
-
This is called when a marker is selected.
Declaration
Swift
@MainActor public func mapView(_ inMapView: MKMapView, didSelect inView: MKAnnotationView )Parameters
inMapViewThe map view
inViewThe marker we’re selecting.
-
This is called when a marker is deselected.
Declaration
Swift
@MainActor public func mapView(_ inMapView: MKMapView, didDeselect inView: MKAnnotationView )Parameters
inMapViewThe map view
inViewThe marker we’re deselecting.
-
Called to determine whether or not to consume a touch event.
Declaration
Swift
@MainActor public func gestureRecognizer(_ inGestureRecognizer: UIGestureRecognizer, shouldReceive inTouch: UITouch ) -> BoolParameters
inGestureRecognizerThe gesture recognizer(ignored)
inTouchThe touch event
Return Value
True, if the touch event is valid.
View on GitHub