-
Notifications
You must be signed in to change notification settings - Fork 0
/
VCMapView.swift
71 lines (51 loc) · 2.23 KB
/
VCMapView.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//
// VCMapView.swift
// Beer Manager
//
// Created by Connor Coughlin on 4/8/17.
// Copyright © 2017 Connor Coughlin. All rights reserved.
//
import Foundation
import MapKit
extension map_view: MKMapViewDelegate {
// 1
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
if let annotation = annotation as? Artwork {
let identifier = "pin"
var view: MKPinAnnotationView
if let dequeuedView = mapView.dequeueReusableAnnotationView(withIdentifier: identifier)
as? MKPinAnnotationView { // 2
dequeuedView.annotation = annotation
view = dequeuedView
} else {
// 3
view = MKPinAnnotationView(annotation: annotation, reuseIdentifier: identifier)
view.canShowCallout = true
view.calloutOffset = CGPoint(x: -5, y: 5)
// view.rightCalloutAccessoryView = UIButton(type: .detailDisclosure) as UIView
let button = UIButton(type: .detailDisclosure)
// button.addTarget(self, action: #selector(map_view.showAnnotationDisclosure(sender: AnyObject.self as AnyObject)), for: .TouchUpInside)
view.rightCalloutAccessoryView = button
}
return view
}
return nil
}
func showAnnotationDisclosure(sender: AnyObject) {
print("Disclosure button clicked")
}
func mapView(_ mapView: MKMapView, annotationView view: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) {
if control == view.rightCalloutAccessoryView {
print("HopCat Pressed!")
performSegue(withIdentifier: "locationBeers", sender: nil)
}
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "locationBeers" {
var destination = segue.destination as! TableCellViewHolder
destination.beer_query = String(1)
destination.searched = false
//destination.fbUserID = fbUserID
}
}
}