Swiftpack.co - sena-mike/SwiftUIAdvancedMap as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by sena-mike.
sena-mike/SwiftUIAdvancedMap 0.06
A wrapper around MKMapView with more functionality than Map.
⭐️ 5
🕓 5 days ago
iOS macOS tvOS
.package(url: "https://github.com/sena-mike/SwiftUIAdvancedMap.git", from: "0.06")



A wrapper around MKMapView with more functionality than Map.

A screenshot of SwiftUIAdvancedMap in action

Feature AdvancedMap MapKit.Map
Tap Gesture with Map coordinates passed into the Handler.
(UIKit Annotation Views)

(SwiftUI Annotation Views)
Drag and Drop Annotations
(UIKit Overlay Views)
Specify EdgeInsets for UI overlays
Display User Location
(via AnnoatationViewFactory)

(as an initialization parameter)
User Tracking Mode
Region State Changing Handler
(Animation in progress)
Animate Changes Control
Binding to Optional map region so map is initially positioned around country bounding box.

Tap or Click Gesture with Coordinate on Map.

struct TappableMap: View {
  @State var rect: MKMapRect? = nil

  var body: some View {
    AdvancedMap(mapRect: $rect) { coordinate in
      print("Tapped on map at: \(coordinate)")

Rendering Annotations

struct TappableMap: View {
  static let annotationViewFactory = AnnotationViewFactory(
    register: { mapView in
      mapView.register(MKMarkerAnnotationView.self, forAnnotationViewWithReuseIdentifier: String(describing: MKPointAnnotation.self))
    view: { mapView, annotation in
      mapView.dequeueReusableAnnotationView(withIdentifier: String(describing: MKPointAnnotation.self), for: annotation)
  @State var rect: MKMapRect? = nil
  @State var annotations: [MKPointAnnotation] = [MKPointAnnotation](https://raw.github.com/sena-mike/SwiftUIAdvancedMap/main/)

  var body: some View {
      mapRect: $rect,
      annotations: annotations,
      annotationViewFactory: TappableMap.annotationViewFactory
    ) { coordinate in
      let annotation = MKPointAnnotation()
      annotation.coordinate = coordinate

Inspired by, and sometimes stealing from, the following projects:


Stars: 5
Last commit: 5 days ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

LongPressGesture and building example project on every commit.
5 days ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics