This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func setupLocationManager(){ | |
// set delegate for location manager | |
if CLLocationManager.authorizationStatus() != CLAuthorizationStatus.authorizedAlways{ | |
// Request to get alwayls location authorization | |
locationManager.requestAlwaysAuthorization() | |
} | |
locationManager.delegate = self | |
locationManager.distanceFilter = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func setupUserNotificationCenter(){ | |
// request to receive notification | |
notificationCenter.requestAuthorization(options: [.alert, .sound, .badge, .carPlay], completionHandler: { (granted, error) in | |
if (error != nil) { | |
print("Notification Authorization Error: " + error!.localizedDescription) | |
}else{ | |
print("Notification Authorization Granted: " + granted.description) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import CoreLocation | |
import UserNotifications | |
@UIApplicationMain | |
class AppDelegate: UIResponder, UIApplicationDelegate, CLLocationManagerDelegate, UNUserNotificationCenterDelegate{ | |
var window: UIWindow? | |
let locationManager = CLLocationManager() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import MapKit | |
import CoreLocation | |
class ViewController: UIViewController, MKMapViewDelegate { | |
@IBOutlet weak var mapView: MKMapView! | |
override func viewDidLoad() { | |
super.viewDidLoad() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override func viewDidLoad() { | |
super.viewDidLoad() | |
// setup Map View on User Location | |
let noLocation = CLLocationCoordinate2D() | |
let span = MKCoordinateSpan(latitudeDelta: 0.001, longitudeDelta: 0.001) | |
let viewRegion = MKCoordinateRegion(center: noLocation, span: span) | |
mapView.delegate = self | |
mapView.region = viewRegion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func setupMapView(){ | |
var annotationList = [MKPointAnnotation]() | |
var circleList = [MKCircle]() | |
let locationName = "Tokyo Tower" | |
let coordiate = CLLocationCoordinate2DMake(35.658626, 139.745471) | |
// setup annotation | |
let annotation = MKPointAnnotation() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer { | |
let circleRenderer = MKCircleRenderer(overlay: overlay) | |
circleRenderer.strokeColor = UIColor(red: 66/255, green: 133/255, blue: 244/255, alpha: 0.80) | |
circleRenderer.lineWidth = 1.0 | |
circleRenderer.fillColor = UIColor(red: 66/255, green: 133/255, blue: 244/255, alpha: 0.20) | |
return circleRenderer | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func mapView(_ mapView: MKMapView, didUpdate userLocation: MKUserLocation) { | |
let span = MKCoordinateSpan(latitudeDelta: 0.001, longitudeDelta: 0.001) | |
let region = MKCoordinateRegion(center: userLocation.coordinate, span: span) | |
mapView.region = region | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func setupLocationManager(){ | |
if CLLocationManager.authorizationStatus() != CLAuthorizationStatus.authorizedAlways{ | |
// Request to get alwayls location authorization | |
locationManager.requestAlwaysAuthorization() | |
} | |
// set delegate for location manager | |
locationManager.delegate = self | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func setupUserNotificationCenter(){ | |
notificationCenter.delegate = self | |
// request to receive notification | |
notificationCenter.requestAuthorization(options: [.alert, .sound, .badge, .carPlay], completionHandler: { (granted, error) in | |
if (error != nil) { | |
print("Notification Authorization Error: " + error!.localizedDescription) | |
}else{ |
OlderNewer