Skip to content

Instantly share code, notes, and snippets.

@ts95
Created July 18, 2020 23:42
Show Gist options
  • Save ts95/3c0f04f36003c3f8f2213f29d80ce00f to your computer and use it in GitHub Desktop.
Save ts95/3c0f04f36003c3f8f2213f29d80ce00f to your computer and use it in GitHub Desktop.
import SwiftUI
import MapKit
protocol MapAnnotationItem: Identifiable {
associatedtype Annotation: MapAnnotationProtocol
var coordinate: CLLocationCoordinate2D { get }
var annotation: Annotation { get }
}
struct AnyMapAnnotationItem: MapAnnotationItem {
let id: AnyHashable
let coordinate: CLLocationCoordinate2D
let annotation: AnyMapAnnotation
let base: Any
init<T: MapAnnotationItem>(_ base: T) {
self.id = base.id
self.coordinate = base.coordinate
self.annotation = AnyMapAnnotation(base.annotation)
self.base = base
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment