Latest 0.1.2
Homepage https://github.com/fortmarek/AnnotationETA
License MIT
Platforms ios 8.0
Frameworks UIKit, MapKit
Authors

CI Status
Version
Carthage compatible
License
Platform

AnnotationETA

AnnotationETA will easily let you implement MapKit annotations with slick pins, custom colors and cool calloutView showing ETA out of the box!

demo

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

CocoaPods

AnnotationETA is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "AnnotationETA"

Carthage

To integrate AnnotationETA into your Xcode project using Carthage, specify it in your Cartfile:

github "fortmarek/AnnotationETA"

Manually

Include all the files under AnnotationETA/Classes into your project.

Set Up

In func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) set your MKAnnotationView to AnnotationEtaView:

let annotationEtaView = EtaAnnotationView(annotation: annotation, reuseIdentifier: "etaAnnotationIdentifier")
annotationView = annotationEtaView

To display ETA when the annotation is selected:

func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) {
guard let annotation = view.annotation else {return}
if annotation is MKUserLocation {return}

view.leftCalloutAccessoryView = DirectionButton(destinationCoordinate: annotation.coordinate, locationManager: self.locationManager, transportType: .automobile, destinationName: annotation.title ?? "")
}

Detail Button

With detail button you can point to another view controller where you can display additional information about the annotation. Right under initializing etaAnnotationView write this:

annotationEtaView.setDetailShowButton()
annotationEtaView.rightButton?.addTarget(self, action: #selector(detailButtonTapped), for: .touchUpInside)

The action then should trigger function showing the detailViewController and also passing the information from the selected annotation, for example like this:

func detailButtonTapped() {
guard
mapView.selectedAnnotations.count == 1,
let detailViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "detailVC") as? DetailViewController
else {return}

detailViewController.annotation = mapView.selectedAnnotations[0]

self.present(detailViewController, animated: true, completion: nil)
}

Customization

Pin Color

Pin color not only sets the color of the pin, but left and rightCalloutAccessoryView as well

annotationEtaView.pinColor = UIColor.blue

More

For more detailed implementation take a look at the example or contact me.

Author

fortmarek, [email protected]

License

AnnotationETA is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "AnnotationETA",
    "version": "0.1.2",
    "summary": "AnnotationETA will easily let you implement MapKit annotations.",
    "description": "AnnotationETA will easily let you implement MapKit annotations with slick pins, custom colors and cool calloutView showing ETA out of the box!",
    "homepage": "https://github.com/fortmarek/AnnotationETA",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "fortmarek": "[email protected]"
    },
    "source": {
        "git": "https://github.com/fortmarek/AnnotationETA.git",
        "tag": "0.1.2"
    },
    "social_media_url": "https://twitter.com/marekfortCZ",
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "AnnotationETA/Classes/**/*",
    "frameworks": [
        "UIKit",
        "MapKit"
    ],
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This