37 lines
933 B
Swift
37 lines
933 B
Swift
//
|
|
// AddressAnnotations.swift
|
|
// pocloud
|
|
//
|
|
// Created by Patrick McDonagh on 5/24/18.
|
|
// Copyright © 2018 patrickjmcd. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
import MapKit
|
|
import Contacts
|
|
|
|
class GatewayAnnotation : NSObject, MKAnnotation {
|
|
|
|
var coordinate: CLLocationCoordinate2D
|
|
var title: String?
|
|
var subtitle: String?
|
|
var gateway: Gateway?
|
|
|
|
init(coordinate: CLLocationCoordinate2D, title: String, subtitle: String, gateway: Gateway? = nil) {
|
|
self.coordinate = coordinate
|
|
self.title = title
|
|
self.subtitle = subtitle
|
|
self.gateway = gateway
|
|
}
|
|
|
|
func mapItem() -> MKMapItem {
|
|
let addressDict = [CNPostalAddressStreetKey: subtitle!]
|
|
let placemark = MKPlacemark(coordinate: coordinate, addressDictionary: addressDict)
|
|
let mapItem = MKMapItem(placemark: placemark)
|
|
mapItem.name = title
|
|
return mapItem
|
|
}
|
|
|
|
}
|
|
|