//: A MapKit based Playground

import MapKit
import PlaygroundSupport

class Artwork: NSObject, MKAnnotation {
  let title: String?
  let locationName: String?
  let discipline: String?
  let coordinate: CLLocationCoordinate2D

  init(
    title: String?,
    locationName: String?,
    discipline: String?,
    coordinate: CLLocationCoordinate2D
  ) {
    self.title = title
    self.locationName = locationName
    self.discipline = discipline
    self.coordinate = coordinate

    super.init()
  }

  var subtitle: String? {
    return locationName
  }
}

let chatswoodCoordinates = CLLocationCoordinate2DMake(-33.8009948,151.1664372)

// Now let's create a MKMapView
let mapView = MKMapView(frame: CGRect(x:0, y:0, width:800, height:800))

// Define a region for our map view
var mapRegion = MKCoordinateRegion()

let mapRegionSpan = 0.001
mapRegion.center = chatswoodCoordinates
mapRegion.span.latitudeDelta = mapRegionSpan
mapRegion.span.longitudeDelta = mapRegionSpan

mapView.setRegion(mapRegion, animated: true)

// Create a map annotation
let annotation = MKPointAnnotation()
annotation.coordinate = chatswoodCoordinates
annotation.title = "Chatswood"
annotation.subtitle = "Greville"

mapView.addAnnotation(annotation)

// Show artwork on map
let artwork = Artwork(
  title: "The Cheesetree",
  locationName: "Santa Clause Lane",
  discipline: "Nature, like",
  coordinate: CLLocationCoordinate2D(latitude: -33.8010376, longitude: 151.1663819))

mapView.addAnnotation(artwork)

// Add the created mapView to our Playground Live View
PlaygroundPage.current.liveView = mapView
