Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated for swift5 & my location icon is added. #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 25 additions & 14 deletions ARKitNavigationDemo/ARKitNavigationDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -385,20 +385,23 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0900;
LastUpgradeCheck = 0900;
LastUpgradeCheck = 1340;
ORGANIZATIONNAME = "Christopher Webb-Orenstein";
TargetAttributes = {
A74AF08E1F6CA2480000CD5F = {
CreatedOnToolsVersion = 9.0;
ProvisioningStyle = Automatic;
LastSwiftMigration = 1340;
ProvisioningStyle = Manual;
};
A74AF0A41F6CA2490000CD5F = {
CreatedOnToolsVersion = 9.0;
LastSwiftMigration = 1340;
ProvisioningStyle = Automatic;
TestTargetID = A74AF08E1F6CA2480000CD5F;
};
A74AF0AF1F6CA2490000CD5F = {
CreatedOnToolsVersion = 9.0;
LastSwiftMigration = 1340;
ProvisioningStyle = Automatic;
TestTargetID = A74AF08E1F6CA2480000CD5F;
};
Expand Down Expand Up @@ -578,15 +581,18 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
Expand All @@ -612,7 +618,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand All @@ -635,15 +641,18 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
Expand All @@ -663,7 +672,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
Expand All @@ -675,13 +684,14 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 4SZP4Q326F;
CODE_SIGN_STYLE = Manual;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = ARKitNavigationDemo/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.froleeyo.ARKitNavigationDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -690,13 +700,14 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 4SZP4Q326F;
CODE_SIGN_STYLE = Manual;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = ARKitNavigationDemo/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.froleeyo.ARKitNavigationDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand All @@ -712,7 +723,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.froleeyo.ARKitNavigationDemoTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ARKitNavigationDemo.app/ARKitNavigationDemo";
};
Expand All @@ -729,7 +740,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.froleeyo.ARKitNavigationDemoTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ARKitNavigationDemo.app/ARKitNavigationDemo";
};
Expand All @@ -745,7 +756,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.froleeyo.ARKitNavigationDemoUITests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_TARGET_NAME = ARKitNavigationDemo;
};
Expand All @@ -761,7 +772,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.froleeyo.ARKitNavigationDemoUITests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_TARGET_NAME = ARKitNavigationDemo;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
2 changes: 1 addition & 1 deletion ARKitNavigationDemo/ARKitNavigationDemo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
var appCoordinator: MainCoordinator!
// MARK: - App Lifecycle
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
window = UIWindow(frame: UIScreen.main.bounds)
if let window = window {
appCoordinator = MainCoordinator(window: window)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
}
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "blue-arrow-icon.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "hjhladar.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import MapKit

// Get a CLLocation from a route step

extension MKRouteStep {
extension MKRoute.Step {
func getLocation() -> CLLocation {
return CLLocation(latitude: polyline.coordinate.latitude, longitude: polyline.coordinate.longitude)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ struct LocationData {
var destinationLocation: CLLocation!
var annotations: [POIAnnotation]
var legs: [[CLLocationCoordinate2D]]
var steps: [MKRouteStep]
var steps: [MKRoute.Step]
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@

import Foundation

protocol Controller: class {
protocol Controller: AnyObject {
var type: ControllerType { get }
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
import Foundation

protocol AppCoordinator: Coordinator {
weak var delegate: ControllerCoordinatorDelegate? { get set }
var delegate: ControllerCoordinatorDelegate? { get set }
var childCoordinators: [ControllerCoordinator] { get set }
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ typealias RootController = UIViewController & Controller
protocol ControllerCoordinator: Coordinator {
var window: UIWindow { get set }
var rootController: RootController! { get }
weak var delegate: ControllerCoordinatorDelegate? { get set }
var delegate: ControllerCoordinatorDelegate? { get set }
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ import MapKit

protocol ControllerCoordinatorDelegate: CoordinatorDelegate {
func transitionCoordinator(type: CoordinatorType)
func setLocationData(for route: [POIAnnotation], with destination: CLLocation, and legs: [[CLLocationCoordinate2D]], and steps: [MKRouteStep])
func setLocationData(for route: [POIAnnotation], with destination: CLLocation, and legs: [[CLLocationCoordinate2D]], and steps: [MKRoute.Step])
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import MapKit

protocol Mapable: class {
protocol Mapable: AnyObject {
var startingLocation: CLLocation! { get set }
var mapView: MKMapView! { get set }
}
Expand All @@ -21,8 +21,8 @@ extension Mapable {
self.mapView.setCenter(self.startingLocation.coordinate, animated: true)
let latDelta: CLLocationDegrees = 0.004
let lonDelta: CLLocationDegrees = 0.004
let span = MKCoordinateSpanMake(latDelta, lonDelta)
let region = MKCoordinateRegionMake(self.startingLocation.coordinate, span)
let span = MKCoordinateSpan(latitudeDelta: latDelta, longitudeDelta: lonDelta)
let region = MKCoordinateRegion(center: self.startingLocation.coordinate, span: span)
self.mapView.setRegion(region, animated: false)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class StartViewController: UIViewController, Controller {
private var locations: [CLLocation] = []
var startingLocation: CLLocation!
var press: UILongPressGestureRecognizer!
private var steps: [MKRouteStep] = []
private var steps: [MKRoute.Step] = []
var destinationLocation: CLLocationCoordinate2D! {
didSet {
setupNavigation()
Expand All @@ -39,6 +39,7 @@ final class StartViewController: UIViewController, Controller {
press.minimumPressDuration = 0.35
mapView.addGestureRecognizer(press)
mapView.delegate = self
mapView.showsUserLocation = true
} else {
presentMessage(title: "Not Compatible", message: "ARKit is not compatible with this phone.")
return
Expand All @@ -47,7 +48,7 @@ final class StartViewController: UIViewController, Controller {

// Sets destination location to point on map
@objc func handleMapTap(gesture: UIGestureRecognizer) {
if gesture.state != UIGestureRecognizerState.began {
if gesture.state != UIGestureRecognizer.State.began {
return
}
// Get tap point on map
Expand All @@ -69,7 +70,7 @@ final class StartViewController: UIViewController, Controller {
DispatchQueue.global(qos: .default).async {

if self.destinationLocation != nil {
self.navigationService.getDirections(destinationLocation: self.destinationLocation, request: MKDirectionsRequest()) { steps in
self.navigationService.getDirections(destinationLocation: self.destinationLocation, request: MKDirections.Request()) { steps in
for step in steps {
self.annotations.append(POIAnnotation(coordinate: step.getLocation().coordinate, name: "N " + step.instructions))
}
Expand Down Expand Up @@ -151,7 +152,7 @@ final class StartViewController: UIViewController, Controller {
}

// Determines whether leg is first leg or not and routes logic accordingly
private func setTripLegFromStep(_ tripStep: MKRouteStep, and index: Int) {
private func setTripLegFromStep(_ tripStep: MKRoute.Step, and index: Int) {
if index > 0 {
getTripLeg(for: index, and: tripStep)
} else {
Expand All @@ -160,7 +161,7 @@ final class StartViewController: UIViewController, Controller {
}

// Calculates intermediary coordinates for route step that is not first
private func getTripLeg(for index: Int, and tripStep: MKRouteStep) {
private func getTripLeg(for index: Int, and tripStep: MKRoute.Step) {
let previousIndex = index - 1
let previousStep = steps[previousIndex]
let previousLocation = CLLocation(latitude: previousStep.polyline.coordinate.latitude, longitude: previousStep.polyline.coordinate.longitude)
Expand All @@ -170,7 +171,7 @@ final class StartViewController: UIViewController, Controller {
}

// Calculates intermediary coordinates for first route step
private func getInitialLeg(for tripStep: MKRouteStep) {
private func getInitialLeg(for tripStep: MKRoute.Step) {
let nextLocation = CLLocation(latitude: tripStep.polyline.coordinate.latitude, longitude: tripStep.polyline.coordinate.longitude)
let intermediaries = CLLocationCoordinate2D.getIntermediaryLocations(currentLocation: startingLocation, destinationLocation: nextLocation)
currentTripLegs.append(intermediaries)
Expand All @@ -189,7 +190,7 @@ final class StartViewController: UIViewController, Controller {
self.annotationColor = .blue
}
self.mapView?.addAnnotation(annotation)
self.mapView.add(MKCircle(center: annotation.coordinate, radius: 0.2))
self.mapView.addOverlay(MKCircle(center: annotation.coordinate, radius: 0.2))
}
}
}
Expand All @@ -215,6 +216,13 @@ extension StartViewController: MKMapViewDelegate {
let annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: "annotationView") ?? MKAnnotationView()
annotationView.rightCalloutAccessoryView = UIButton(type: .detailDisclosure)
annotationView.canShowCallout = true
if annotation is MKUserLocation {
annotationView.image = UIImage(named: "hjhladar")
var frame = annotationView.frame
frame.size.height = 50
frame.size.width = 50
annotationView.frame = frame
}
return annotationView
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ import MapKit

protocol StartViewControllerDelegate: class {
func startNavigation(tapped: Bool)
func startNavigation(with route: [POIAnnotation], for destination: CLLocation, and legs: [[CLLocationCoordinate2D]], and step: [MKRouteStep])
func startNavigation(with route: [POIAnnotation], for destination: CLLocation, and legs: [[CLLocationCoordinate2D]], and step: [MKRoute.Step])
}
Loading