Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Ariba Siddiqui
MapKit Directions
Commits
1377bbc9
Commit
1377bbc9
authored
Nov 29, 2021
by
Ariba Siddiqui
Browse files
Revert "comments for directions and other restructuring"
This reverts commit
05261150
parent
05261150
Changes
8
Hide whitespace changes
Inline
Side-by-side
.DS_Store
View file @
1377bbc9
No preview for this file type
Location Tutorial.xcodeproj/project.pbxproj
View file @
1377bbc9
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
objects
=
{
objects
=
{
/* Begin PBXBuildFile section */
/* Begin PBXBuildFile section */
09AD0D752753EF1C00E400F7
/* MapSerachView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
09AD0D742753EF1C00E400F7
/* MapSerachView.swift */
;
};
09AD0D772753EF5000E400F7
/* LocationSearch.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
09AD0D762753EF5000E400F7
/* LocationSearch.swift */
;
};
09AD0D772753EF5000E400F7
/* LocationSearch.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
09AD0D762753EF5000E400F7
/* LocationSearch.swift */
;
};
2517A35527502266006F2B81
/* AppDelegate.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
2517A35427502266006F2B81
/* AppDelegate.swift */
;
};
2517A35527502266006F2B81
/* AppDelegate.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
2517A35427502266006F2B81
/* AppDelegate.swift */
;
};
2517A35727502266006F2B81
/* SceneDelegate.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
2517A35627502266006F2B81
/* SceneDelegate.swift */
;
};
2517A35727502266006F2B81
/* SceneDelegate.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
2517A35627502266006F2B81
/* SceneDelegate.swift */
;
};
...
@@ -37,6 +38,7 @@
...
@@ -37,6 +38,7 @@
/* End PBXContainerItemProxy section */
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
/* Begin PBXFileReference section */
09AD0D742753EF1C00E400F7
/* MapSerachView.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MapSerachView.swift
;
sourceTree
=
"<group>"
;
};
09AD0D762753EF5000E400F7
/* LocationSearch.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
LocationSearch.swift
;
sourceTree
=
"<group>"
;
};
09AD0D762753EF5000E400F7
/* LocationSearch.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
LocationSearch.swift
;
sourceTree
=
"<group>"
;
};
2517A35127502266006F2B81
/* Location Tutorial.app */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.application
;
includeInIndex
=
0
;
path
=
"Location Tutorial.app"
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
2517A35127502266006F2B81
/* Location Tutorial.app */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.application
;
includeInIndex
=
0
;
path
=
"Location Tutorial.app"
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
2517A35427502266006F2B81
/* AppDelegate.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
AppDelegate.swift
;
sourceTree
=
"<group>"
;
};
2517A35427502266006F2B81
/* AppDelegate.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
AppDelegate.swift
;
sourceTree
=
"<group>"
;
};
...
@@ -108,6 +110,7 @@
...
@@ -108,6 +110,7 @@
2517A35D2750226C006F2B81
/* Assets.xcassets */
,
2517A35D2750226C006F2B81
/* Assets.xcassets */
,
2517A35F2750226C006F2B81
/* LaunchScreen.storyboard */
,
2517A35F2750226C006F2B81
/* LaunchScreen.storyboard */
,
2517A3622750226C006F2B81
/* Info.plist */
,
2517A3622750226C006F2B81
/* Info.plist */
,
09AD0D742753EF1C00E400F7
/* MapSerachView.swift */
,
09AD0D762753EF5000E400F7
/* LocationSearch.swift */
,
09AD0D762753EF5000E400F7
/* LocationSearch.swift */
,
);
);
path
=
"Location Tutorial"
;
path
=
"Location Tutorial"
;
...
@@ -263,6 +266,7 @@
...
@@ -263,6 +266,7 @@
files
=
(
files
=
(
09AD0D772753EF5000E400F7
/* LocationSearch.swift in Sources */
,
09AD0D772753EF5000E400F7
/* LocationSearch.swift in Sources */
,
2517A35927502266006F2B81
/* ViewController.swift in Sources */
,
2517A35927502266006F2B81
/* ViewController.swift in Sources */
,
09AD0D752753EF1C00E400F7
/* MapSerachView.swift in Sources */
,
2517A35527502266006F2B81
/* AppDelegate.swift in Sources */
,
2517A35527502266006F2B81
/* AppDelegate.swift in Sources */
,
2517A35727502266006F2B81
/* SceneDelegate.swift in Sources */
,
2517A35727502266006F2B81
/* SceneDelegate.swift in Sources */
,
);
);
...
...
Location Tutorial.xcodeproj/project.xcworkspace/xcuserdata/aribasiddiqui.xcuserdatad/UserInterfaceState.xcuserstate
View file @
1377bbc9
No preview for this file type
Location Tutorial.xcodeproj/xcuserdata/aribasiddiqui.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
View file @
1377bbc9
...
@@ -14,8 +14,8 @@
...
@@ -14,8 +14,8 @@
filePath =
"Location Tutorial/ViewController.swift"
filePath =
"Location Tutorial/ViewController.swift"
startingColumnNumber =
"9223372036854775807"
startingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"8
4
"
startingLineNumber =
"8
6
"
endingLineNumber =
"8
4
"
endingLineNumber =
"8
6
"
landmarkName =
"goButtonTapped(_:)"
landmarkName =
"goButtonTapped(_:)"
landmarkType =
"7"
>
landmarkType =
"7"
>
</BreakpointContent>
</BreakpointContent>
...
@@ -30,8 +30,8 @@
...
@@ -30,8 +30,8 @@
filePath =
"Location Tutorial/ViewController.swift"
filePath =
"Location Tutorial/ViewController.swift"
startingColumnNumber =
"9223372036854775807"
startingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"10
3
"
startingLineNumber =
"10
5
"
endingLineNumber =
"10
3
"
endingLineNumber =
"10
5
"
landmarkName =
"getDirections()"
landmarkName =
"getDirections()"
landmarkType =
"7"
>
landmarkType =
"7"
>
</BreakpointContent>
</BreakpointContent>
...
@@ -46,8 +46,8 @@
...
@@ -46,8 +46,8 @@
filePath =
"Location Tutorial/ViewController.swift"
filePath =
"Location Tutorial/ViewController.swift"
startingColumnNumber =
"9223372036854775807"
startingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"10
4
"
startingLineNumber =
"10
6
"
endingLineNumber =
"10
4
"
endingLineNumber =
"10
6
"
landmarkName =
"getDirections()"
landmarkName =
"getDirections()"
landmarkType =
"7"
>
landmarkType =
"7"
>
</BreakpointContent>
</BreakpointContent>
...
@@ -62,10 +62,58 @@
...
@@ -62,10 +62,58 @@
filePath =
"Location Tutorial/ViewController.swift"
filePath =
"Location Tutorial/ViewController.swift"
startingColumnNumber =
"9223372036854775807"
startingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"105"
startingLineNumber =
"107"
endingLineNumber =
"105"
endingLineNumber =
"107"
landmarkName =
"getDirections()"
landmarkType =
"7"
>
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID =
"Xcode.Breakpoint.FileBreakpoint"
>
<BreakpointContent
uuid =
"298D89E0-B8E7-4739-97A7-7799C4E2704E"
shouldBeEnabled =
"No"
ignoreCount =
"0"
continueAfterRunningActions =
"No"
filePath =
"Location Tutorial/ViewController.swift"
startingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"109"
endingLineNumber =
"109"
landmarkName =
"getDirections()"
landmarkName =
"getDirections()"
landmarkType =
"7"
>
landmarkType =
"7"
>
<Locations>
<Location
uuid =
"298D89E0-B8E7-4739-97A7-7799C4E2704E - 5a8fd180874c388"
shouldBeEnabled =
"Yes"
ignoreCount =
"0"
continueAfterRunningActions =
"No"
symbolName =
"Location_Tutorial.ViewController.getDirections() -> ()"
moduleName =
"Location Tutorial"
usesParentBreakpointCondition =
"Yes"
urlString =
"file:///Users/aribasiddiqui/Downloads/Location%20Tutorial/Location%20Tutorial/ViewController.swift"
startingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"100"
endingLineNumber =
"100"
offsetFromSymbolStart =
"428"
>
</Location>
<Location
uuid =
"298D89E0-B8E7-4739-97A7-7799C4E2704E - 53aed4c77a2b419f"
shouldBeEnabled =
"Yes"
ignoreCount =
"0"
continueAfterRunningActions =
"No"
symbolName =
"closure #1 (Swift.Optional<__C.MKDirectionsResponse>, Swift.Optional<Swift.Error>) -> () in Location_Tutorial.ViewController.getDirections() -> ()"
moduleName =
"Location Tutorial"
usesParentBreakpointCondition =
"Yes"
urlString =
"file:///Users/aribasiddiqui/Downloads/Location%20Tutorial/Location%20Tutorial/ViewController.swift"
startingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"100"
endingLineNumber =
"100"
offsetFromSymbolStart =
"108"
>
</Location>
</Locations>
</BreakpointContent>
</BreakpointContent>
</BreakpointProxy>
</BreakpointProxy>
<BreakpointProxy
<BreakpointProxy
...
@@ -78,8 +126,8 @@
...
@@ -78,8 +126,8 @@
filePath =
"Location Tutorial/ViewController.swift"
filePath =
"Location Tutorial/ViewController.swift"
startingColumnNumber =
"9223372036854775807"
startingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"11
3
"
startingLineNumber =
"11
1
"
endingLineNumber =
"11
3
"
endingLineNumber =
"11
1
"
landmarkName =
"getDirections()"
landmarkName =
"getDirections()"
landmarkType =
"7"
>
landmarkType =
"7"
>
</BreakpointContent>
</BreakpointContent>
...
@@ -94,8 +142,8 @@
...
@@ -94,8 +142,8 @@
filePath =
"Location Tutorial/ViewController.swift"
filePath =
"Location Tutorial/ViewController.swift"
startingColumnNumber =
"9223372036854775807"
startingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"11
9
"
startingLineNumber =
"11
3
"
endingLineNumber =
"11
9
"
endingLineNumber =
"11
3
"
landmarkName =
"getDirections()"
landmarkName =
"getDirections()"
landmarkType =
"7"
>
landmarkType =
"7"
>
</BreakpointContent>
</BreakpointContent>
...
@@ -110,8 +158,8 @@
...
@@ -110,8 +158,8 @@
filePath =
"Location Tutorial/ViewController.swift"
filePath =
"Location Tutorial/ViewController.swift"
startingColumnNumber =
"9223372036854775807"
startingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"1
20
"
startingLineNumber =
"1
14
"
endingLineNumber =
"1
20
"
endingLineNumber =
"1
14
"
landmarkName =
"getDirections()"
landmarkName =
"getDirections()"
landmarkType =
"7"
>
landmarkType =
"7"
>
</BreakpointContent>
</BreakpointContent>
...
@@ -126,12 +174,28 @@
...
@@ -126,12 +174,28 @@
filePath =
"Location Tutorial/ViewController.swift"
filePath =
"Location Tutorial/ViewController.swift"
startingColumnNumber =
"9223372036854775807"
startingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"1
26
"
startingLineNumber =
"1
19
"
endingLineNumber =
"1
26
"
endingLineNumber =
"1
19
"
landmarkName =
"getDirections()"
landmarkName =
"getDirections()"
landmarkType =
"7"
>
landmarkType =
"7"
>
</BreakpointContent>
</BreakpointContent>
</BreakpointProxy>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID =
"Xcode.Breakpoint.FileBreakpoint"
>
<BreakpointContent
uuid =
"09F7531A-1930-428C-96D6-F706EE65214C"
shouldBeEnabled =
"No"
ignoreCount =
"0"
continueAfterRunningActions =
"No"
filePath =
"Location Tutorial/ViewController.swift"
startingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"125"
endingLineNumber =
"125"
landmarkName =
"createDirectionsRequest(from:)"
landmarkType =
"7"
>
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
<BreakpointProxy
BreakpointExtensionID =
"Xcode.Breakpoint.FileBreakpoint"
>
BreakpointExtensionID =
"Xcode.Breakpoint.FileBreakpoint"
>
<BreakpointContent
<BreakpointContent
...
@@ -142,8 +206,24 @@
...
@@ -142,8 +206,24 @@
filePath =
"Location Tutorial/ViewController.swift"
filePath =
"Location Tutorial/ViewController.swift"
startingColumnNumber =
"9223372036854775807"
startingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"134"
startingLineNumber =
"126"
endingLineNumber =
"134"
endingLineNumber =
"126"
landmarkName =
"createDirectionsRequest(from:)"
landmarkType =
"7"
>
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID =
"Xcode.Breakpoint.FileBreakpoint"
>
<BreakpointContent
uuid =
"C3FEF63B-F36D-41E8-80DF-D4F88C907C81"
shouldBeEnabled =
"No"
ignoreCount =
"0"
continueAfterRunningActions =
"No"
filePath =
"Location Tutorial/ViewController.swift"
startingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"128"
endingLineNumber =
"128"
landmarkName =
"createDirectionsRequest(from:)"
landmarkName =
"createDirectionsRequest(from:)"
landmarkType =
"7"
>
landmarkType =
"7"
>
</BreakpointContent>
</BreakpointContent>
...
@@ -158,8 +238,8 @@
...
@@ -158,8 +238,8 @@
filePath =
"Location Tutorial/ViewController.swift"
filePath =
"Location Tutorial/ViewController.swift"
startingColumnNumber =
"9223372036854775807"
startingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"1
35
"
startingLineNumber =
"1
27
"
endingLineNumber =
"1
35
"
endingLineNumber =
"1
27
"
landmarkName =
"createDirectionsRequest(from:)"
landmarkName =
"createDirectionsRequest(from:)"
landmarkType =
"7"
>
landmarkType =
"7"
>
</BreakpointContent>
</BreakpointContent>
...
@@ -174,12 +254,28 @@
...
@@ -174,12 +254,28 @@
filePath =
"Location Tutorial/ViewController.swift"
filePath =
"Location Tutorial/ViewController.swift"
startingColumnNumber =
"9223372036854775807"
startingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"1
36
"
startingLineNumber =
"1
29
"
endingLineNumber =
"1
36
"
endingLineNumber =
"1
29
"
landmarkName =
"createDirectionsRequest(from:)"
landmarkName =
"createDirectionsRequest(from:)"
landmarkType =
"7"
>
landmarkType =
"7"
>
</BreakpointContent>
</BreakpointContent>
</BreakpointProxy>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID =
"Xcode.Breakpoint.FileBreakpoint"
>
<BreakpointContent
uuid =
"62E4DD88-9016-4FF0-9C32-5FBF2E22A604"
shouldBeEnabled =
"Yes"
ignoreCount =
"0"
continueAfterRunningActions =
"No"
filePath =
"Location Tutorial/ViewController.swift"
startingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"140"
endingLineNumber =
"140"
landmarkName =
"resetMapView(withNew:)"
landmarkType =
"7"
>
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
<BreakpointProxy
BreakpointExtensionID =
"Xcode.Breakpoint.FileBreakpoint"
>
BreakpointExtensionID =
"Xcode.Breakpoint.FileBreakpoint"
>
<BreakpointContent
<BreakpointContent
...
@@ -190,8 +286,8 @@
...
@@ -190,8 +286,8 @@
filePath =
"Location Tutorial/ViewController.swift"
filePath =
"Location Tutorial/ViewController.swift"
startingColumnNumber =
"9223372036854775807"
startingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"10
8
"
startingLineNumber =
"1
1
0"
endingLineNumber =
"10
8
"
endingLineNumber =
"1
1
0"
landmarkName =
"getDirections()"
landmarkName =
"getDirections()"
landmarkType =
"7"
>
landmarkType =
"7"
>
</BreakpointContent>
</BreakpointContent>
...
@@ -206,8 +302,8 @@
...
@@ -206,8 +302,8 @@
filePath =
"Location Tutorial/ViewController.swift"
filePath =
"Location Tutorial/ViewController.swift"
startingColumnNumber =
"9223372036854775807"
startingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"1
72
"
startingLineNumber =
"1
65
"
endingLineNumber =
"1
72
"
endingLineNumber =
"1
65
"
landmarkName =
"mapView(_:rendererFor:)"
landmarkName =
"mapView(_:rendererFor:)"
landmarkType =
"7"
>
landmarkType =
"7"
>
</BreakpointContent>
</BreakpointContent>
...
@@ -222,8 +318,8 @@
...
@@ -222,8 +318,8 @@
filePath =
"Location Tutorial/ViewController.swift"
filePath =
"Location Tutorial/ViewController.swift"
startingColumnNumber =
"9223372036854775807"
startingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"1
71
"
startingLineNumber =
"1
64
"
endingLineNumber =
"1
71
"
endingLineNumber =
"1
64
"
landmarkName =
"mapView(_:rendererFor:)"
landmarkName =
"mapView(_:rendererFor:)"
landmarkType =
"7"
>
landmarkType =
"7"
>
</BreakpointContent>
</BreakpointContent>
...
...
Location Tutorial/Base.lproj/Main.storyboard
View file @
1377bbc9
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
<rect
key=
"frame"
x=
"0.0"
y=
"0.0"
width=
"414"
height=
"896"
/>
<rect
key=
"frame"
x=
"0.0"
y=
"0.0"
width=
"414"
height=
"896"
/>
<autoresizingMask
key=
"autoresizingMask"
widthSizable=
"YES"
heightSizable=
"YES"
/>
<autoresizingMask
key=
"autoresizingMask"
widthSizable=
"YES"
heightSizable=
"YES"
/>
<subviews>
<subviews>
<mapView
clipsSubviews=
"YES"
multipleTouchEnabled=
"YES"
contentMode=
"scaleToFill"
mapType=
"standard"
showsUserLocation=
"YES"
showsCompass=
"NO"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"eRy-hV-Pvo"
>
<mapView
clipsSubviews=
"YES"
multipleTouchEnabled=
"YES"
contentMode=
"scaleToFill"
mapType=
"standard"
showsUserLocation=
"YES"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"eRy-hV-Pvo"
>
<rect
key=
"frame"
x=
"0.0"
y=
"0.0"
width=
"414"
height=
"896"
/>
<rect
key=
"frame"
x=
"0.0"
y=
"0.0"
width=
"414"
height=
"896"
/>
</mapView>
</mapView>
<button
opaque=
"NO"
contentMode=
"scaleToFill"
fixedFrame=
"YES"
contentHorizontalAlignment=
"center"
contentVerticalAlignment=
"center"
buttonType=
"system"
lineBreakMode=
"middleTruncation"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"ac8-fP-bc3"
>
<button
opaque=
"NO"
contentMode=
"scaleToFill"
fixedFrame=
"YES"
contentHorizontalAlignment=
"center"
contentVerticalAlignment=
"center"
buttonType=
"system"
lineBreakMode=
"middleTruncation"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"ac8-fP-bc3"
>
...
...
Location Tutorial/LocationSearch.swift
View file @
1377bbc9
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
// LocationFinder.swift
// LocationFinder.swift
// MapKit Testing Search Functionality
// MapKit Testing Search Functionality
//
//
// Created by Brian Porumb on 25.11.21.
//
import
Foundation
import
Foundation
import
Combine
import
Combine
...
@@ -9,7 +11,7 @@ import MapKit
...
@@ -9,7 +11,7 @@ import MapKit
class
LocationService
:
NSObject
,
ObservableObject
{
class
LocationService
:
NSObject
,
ObservableObject
{
// Differ
e
nt search states
// Differnt search states
enum
LocationStatus
:
Equatable
{
enum
LocationStatus
:
Equatable
{
case
idle
case
idle
case
noResults
case
noResults
...
...
Location Tutorial/MapSe
a
rchView.swift
→
Location Tutorial/MapSer
a
chView.swift
View file @
1377bbc9
//
//
//
MapSearch
View.swift
//
Content
View.swift
// MapKit Testing Search Functionality
// MapKit Testing Search Functionality
//
//
// Created by Brian Porumb on 25.11.21.
//
import
SwiftUI
import
SwiftUI
...
...
Location Tutorial/ViewController.swift
View file @
1377bbc9
//
//
// ViewController.swift
// ViewController.swift
// MapKit Routing, Annotations and Location
// Location Tutorial
//
// Created by Huang on 2021/11/25.
//
//
import
UIKit
import
UIKit
...
@@ -12,31 +14,26 @@ class ViewController: UIViewController {
...
@@ -12,31 +14,26 @@ class ViewController: UIViewController {
@IBOutlet
weak
var
mapView
:
MKMapView
!
@IBOutlet
weak
var
mapView
:
MKMapView
!
let
locationManager
=
CLLocationManager
()
let
locationManager
=
CLLocationManager
()
var
regionInMeters
:
Double
=
10000
//scale of the map
var
regionInMeters
:
Double
=
10000
//scale of the map
// ### code for directions start ###
var
directionsArray
:
[
MKDirections
]
=
[]
var
directionsArray
:
[
MKDirections
]
=
[]
// ### code for directions end ###
override
func
viewDidLoad
()
{
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
checkLocationServices
()
checkLocationServices
()
setupMapView
()
setupMapView
()
}
}
func
setupMapView
(){
mapView
.
delegate
=
self
}
func
setupLocationManager
()
{
func
setupLocationManager
()
{
locationManager
.
delegate
=
self
locationManager
.
delegate
=
self
locationManager
.
desiredAccuracy
=
kCLLocationAccuracyBest
locationManager
.
desiredAccuracy
=
kCLLocationAccuracyBest
}
}
// helper function to display alerts to user
func
displayAlert
(
alertTitle
:
String
,
alertMessage
:
String
)
{
let
alert
=
UIAlertController
(
title
:
alertTitle
,
message
:
alertMessage
,
preferredStyle
:
.
alert
)
alert
.
addAction
(
UIAlertAction
(
title
:
"OK"
,
style
:
.
default
,
handler
:
nil
))
alert
.
addAction
(
UIAlertAction
(
title
:
"Cancel"
,
style
:
.
cancel
,
handler
:
nil
))
self
.
present
(
alert
,
animated
:
true
)
}
func
centerViewOnUserLocation
()
{
func
centerViewOnUserLocation
()
{
if
let
location
=
locationManager
.
location
?
.
coordinate
{
if
let
location
=
locationManager
.
location
?
.
coordinate
{
let
region
=
MKCoordinateRegion
.
init
(
center
:
location
,
latitudinalMeters
:
regionInMeters
,
longitudinalMeters
:
regionInMeters
)
let
region
=
MKCoordinateRegion
.
init
(
center
:
location
,
latitudinalMeters
:
regionInMeters
,
longitudinalMeters
:
regionInMeters
)
...
@@ -44,18 +41,18 @@ class ViewController: UIViewController {
...
@@ -44,18 +41,18 @@ class ViewController: UIViewController {
}
}
}
}
// check if user's location services are enabled
func
checkLocationServices
()
{
func
checkLocationServices
()
{
if
CLLocationManager
.
locationServicesEnabled
()
{
if
CLLocationManager
.
locationServicesEnabled
()
{
setupLocationManager
()
setupLocationManager
()
checkLocationAuthorization
()
checkLocationAuthorization
()
}
else
{
}
else
{
print
(
"Location Services are not enabled"
)
// Show alert letting the user know they have to turn this on.
displayAlert
(
alertTitle
:
"Location Services are not turned on"
,
alertMessage
:
"You must enable your Location Services to perform this action"
)
}
}
}
}
// checking authorization status
func
checkLocationAuthorization
()
{
func
checkLocationAuthorization
()
{
let
manager
=
CLLocationManager
()
let
manager
=
CLLocationManager
()
switch
manager
.
authorizationStatus
{
switch
manager
.
authorizationStatus
{
...
@@ -79,24 +76,29 @@ class ViewController: UIViewController {
...
@@ -79,24 +76,29 @@ class ViewController: UIViewController {
}
}
}
}
// action triggered on the "GO" button tap
// ### code for directions start ###
func
setupMapView
(){
mapView
.
delegate
=
self
}
@IBAction
func
goButtonTapped
(
_
sender
:
Any
)
{
@IBAction
func
goButtonTapped
(
_
sender
:
Any
)
{
print
(
"GO button tapped"
)
print
(
"GO button tapped"
)
getDirections
()
getDirections
()
}
}
//to prevent throttling and multiple renders
func
getLocationCoordinates
()
->
CLLocationCoordinate2D
{
func
resetMapView
(
withNew
directions
:
MKDirections
)
{
let
cologne
=
MKPointAnnotation
()
mapView
.
removeOverlays
(
mapView
.
overlays
)
cologne
.
title
=
"Cologne"
directionsArray
.
append
(
directions
)
cologne
.
coordinate
=
CLLocationCoordinate2D
(
latitude
:
50.9375
,
longitude
:
6.9603
)
let
_
=
directionsArray
.
map
{
$0
.
cancel
()
}
mapView
.
addAnnotation
(
cologne
)
return
cologne
.
coordinate
//hard coded coordinates for Cologne
}
}
// main function for routing
func
getDirections
()
{
func
getDirections
()
{
guard
let
location
=
locationManager
.
location
?
.
coordinate
else
{
guard
let
location
=
locationManager
.
location
?
.
coordinate
else
{
print
(
"Location not found"
)
//TODO: Inform user we don't have their current location
displayAlert
(
alertTitle
:
"Location not found"
,
alertMessage
:
"App cannot access your location"
)