diff options
Diffstat (limited to 'platform/ios/demo/Examples/Swift/CustomAnnotationModels.swift')
-rw-r--r-- | platform/ios/demo/Examples/Swift/CustomAnnotationModels.swift | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/platform/ios/demo/Examples/Swift/CustomAnnotationModels.swift b/platform/ios/demo/Examples/Swift/CustomAnnotationModels.swift new file mode 100644 index 0000000000..fba168d29b --- /dev/null +++ b/platform/ios/demo/Examples/Swift/CustomAnnotationModels.swift @@ -0,0 +1,28 @@ +import Mapbox + +// MGLAnnotation protocol reimplementation + +class CustomPointAnnotation: NSObject, MGLAnnotation { + // As a reimplementation of the MGLAnnotation protocol, we have to add mutable coordinate and (sub)title properties ourselves. + var coordinate: CLLocationCoordinate2D + var title: String? + var subtitle: String? + + // Custom properties that we will use to customize the annotation's image. + var image: UIImage? + var reuseIdentifier: String? + + init(coordinate: CLLocationCoordinate2D, title: String?, subtitle: String?) { + self.coordinate = coordinate + self.title = title + self.subtitle = subtitle + } +} + +// MGLPolyline subclass +class CustomPolyline: MGLPolyline { + // Because this is a subclass of MGLPolyline, there is no need to redeclare its properties. + + // Custom property that we will use when drawing the polyline. + var color: UIColor? +} |