-
Notifications
You must be signed in to change notification settings - Fork 0
/
mapPage.swift
64 lines (48 loc) · 2.18 KB
/
mapPage.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
//
// mapPage.swift
// Beer Manager
//
// Created by Connor Coughlin on 3/31/17.
// Copyright © 2017 Connor Coughlin. All rights reserved.
//
import Foundation
import UIKit
import MapKit
class map_view: UIViewController {
@IBOutlet weak var mapView: MKMapView!
override func viewDidLoad() {
super.viewDidLoad()
let initialLocation = CLLocation(latitude: 42.2808, longitude: -83.7430)
centerMapOnLocation(location: initialLocation)
mapView.delegate = self
var artwork = Artwork(title: "Hopcat",
locationName: "Brewery",
discipline: "Brewery",
coordinate: CLLocationCoordinate2D(latitude: 42.2791, longitude: -83.7418))
mapView.addAnnotation(artwork)
artwork = Artwork(title: "Arbor Brewing Company",
locationName: "Brewery",
discipline: "Brewery",
coordinate: CLLocationCoordinate2D(latitude: 42.2803, longitude: -83.7478))
mapView.addAnnotation(artwork)
artwork = Artwork(title: "Jolly Pumpkin",
locationName: "Brewery",
discipline: "Brewery",
coordinate: CLLocationCoordinate2D(latitude: 42.2792, longitude: -83.7485))
mapView.addAnnotation(artwork)
}
// override func viewDidAppear(_ animated: Bool) {
// let artwork = Artwork(title: "Hopcat",
// locationName: "Brewery",
// discipline: "Brewery",
// coordinate: CLLocationCoordinate2D(latitude: 42.2791, longitude: -83.7418))
//
// mapView.addAnnotation(artwork)
// }
let regionRadius: CLLocationDistance = 1000
func centerMapOnLocation(location: CLLocation) {
let coordinateRegion = MKCoordinateRegionMakeWithDistance(location.coordinate,
regionRadius * 2.0, regionRadius * 2.0)
mapView.setRegion(coordinateRegion, animated: true)
}
}