├── LICENSE ├── MapKitTutorial.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── robertchen.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── robertchen.xcuserdatad │ └── xcschemes │ ├── MapKitTutorial.xcscheme │ └── xcschememanagement.plist ├── MapKitTutorial ├── AppDelegate.swift ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ └── car.imageset │ │ ├── Contents.json │ │ ├── fa-car_30_0_000000_none.png │ │ ├── fa-car_60_0_000000_none.png │ │ └── fa-car_90_0_000000_none.png ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── LocationSearchTable.swift └── ViewController.swift └── README.md /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 Thorn Technologies LLC 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /MapKitTutorial.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | FC1E247C1C2B10F5009E9908 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC1E247B1C2B10F5009E9908 /* AppDelegate.swift */; }; 11 | FC1E247E1C2B10F5009E9908 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC1E247D1C2B10F5009E9908 /* ViewController.swift */; }; 12 | FC1E24811C2B10F5009E9908 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FC1E247F1C2B10F5009E9908 /* Main.storyboard */; }; 13 | FC1E24831C2B10F5009E9908 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = FC1E24821C2B10F5009E9908 /* Assets.xcassets */; }; 14 | FC1E24861C2B10F5009E9908 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FC1E24841C2B10F5009E9908 /* LaunchScreen.storyboard */; }; 15 | FCC472811C31DAD600E8FEEC /* LocationSearchTable.swift in Sources */ = {isa = PBXBuildFile; fileRef = FCC472801C31DAD600E8FEEC /* LocationSearchTable.swift */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXFileReference section */ 19 | FC1E24781C2B10F5009E9908 /* MapKitTutorial.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MapKitTutorial.app; sourceTree = BUILT_PRODUCTS_DIR; }; 20 | FC1E247B1C2B10F5009E9908 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 21 | FC1E247D1C2B10F5009E9908 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 22 | FC1E24801C2B10F5009E9908 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 23 | FC1E24821C2B10F5009E9908 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 24 | FC1E24851C2B10F5009E9908 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 25 | FC1E24871C2B10F5009E9908 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 26 | FCC472801C31DAD600E8FEEC /* LocationSearchTable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LocationSearchTable.swift; sourceTree = ""; }; 27 | /* End PBXFileReference section */ 28 | 29 | /* Begin PBXFrameworksBuildPhase section */ 30 | FC1E24751C2B10F5009E9908 /* Frameworks */ = { 31 | isa = PBXFrameworksBuildPhase; 32 | buildActionMask = 2147483647; 33 | files = ( 34 | ); 35 | runOnlyForDeploymentPostprocessing = 0; 36 | }; 37 | /* End PBXFrameworksBuildPhase section */ 38 | 39 | /* Begin PBXGroup section */ 40 | FC1E246F1C2B10F5009E9908 = { 41 | isa = PBXGroup; 42 | children = ( 43 | FC1E247A1C2B10F5009E9908 /* MapKitTutorial */, 44 | FC1E24791C2B10F5009E9908 /* Products */, 45 | ); 46 | sourceTree = ""; 47 | }; 48 | FC1E24791C2B10F5009E9908 /* Products */ = { 49 | isa = PBXGroup; 50 | children = ( 51 | FC1E24781C2B10F5009E9908 /* MapKitTutorial.app */, 52 | ); 53 | name = Products; 54 | sourceTree = ""; 55 | }; 56 | FC1E247A1C2B10F5009E9908 /* MapKitTutorial */ = { 57 | isa = PBXGroup; 58 | children = ( 59 | FC1E247B1C2B10F5009E9908 /* AppDelegate.swift */, 60 | FC1E247D1C2B10F5009E9908 /* ViewController.swift */, 61 | FC1E247F1C2B10F5009E9908 /* Main.storyboard */, 62 | FCC472801C31DAD600E8FEEC /* LocationSearchTable.swift */, 63 | FC1E24821C2B10F5009E9908 /* Assets.xcassets */, 64 | FC1E24841C2B10F5009E9908 /* LaunchScreen.storyboard */, 65 | FC1E24871C2B10F5009E9908 /* Info.plist */, 66 | ); 67 | path = MapKitTutorial; 68 | sourceTree = ""; 69 | }; 70 | /* End PBXGroup section */ 71 | 72 | /* Begin PBXNativeTarget section */ 73 | FC1E24771C2B10F5009E9908 /* MapKitTutorial */ = { 74 | isa = PBXNativeTarget; 75 | buildConfigurationList = FC1E248A1C2B10F5009E9908 /* Build configuration list for PBXNativeTarget "MapKitTutorial" */; 76 | buildPhases = ( 77 | FC1E24741C2B10F5009E9908 /* Sources */, 78 | FC1E24751C2B10F5009E9908 /* Frameworks */, 79 | FC1E24761C2B10F5009E9908 /* Resources */, 80 | ); 81 | buildRules = ( 82 | ); 83 | dependencies = ( 84 | ); 85 | name = MapKitTutorial; 86 | productName = MapKitTutorial; 87 | productReference = FC1E24781C2B10F5009E9908 /* MapKitTutorial.app */; 88 | productType = "com.apple.product-type.application"; 89 | }; 90 | /* End PBXNativeTarget section */ 91 | 92 | /* Begin PBXProject section */ 93 | FC1E24701C2B10F5009E9908 /* Project object */ = { 94 | isa = PBXProject; 95 | attributes = { 96 | LastSwiftUpdateCheck = 0720; 97 | LastUpgradeCheck = 0720; 98 | ORGANIZATIONNAME = "Thorn Technologies"; 99 | TargetAttributes = { 100 | FC1E24771C2B10F5009E9908 = { 101 | CreatedOnToolsVersion = 7.2; 102 | }; 103 | }; 104 | }; 105 | buildConfigurationList = FC1E24731C2B10F5009E9908 /* Build configuration list for PBXProject "MapKitTutorial" */; 106 | compatibilityVersion = "Xcode 3.2"; 107 | developmentRegion = English; 108 | hasScannedForEncodings = 0; 109 | knownRegions = ( 110 | en, 111 | Base, 112 | ); 113 | mainGroup = FC1E246F1C2B10F5009E9908; 114 | productRefGroup = FC1E24791C2B10F5009E9908 /* Products */; 115 | projectDirPath = ""; 116 | projectRoot = ""; 117 | targets = ( 118 | FC1E24771C2B10F5009E9908 /* MapKitTutorial */, 119 | ); 120 | }; 121 | /* End PBXProject section */ 122 | 123 | /* Begin PBXResourcesBuildPhase section */ 124 | FC1E24761C2B10F5009E9908 /* Resources */ = { 125 | isa = PBXResourcesBuildPhase; 126 | buildActionMask = 2147483647; 127 | files = ( 128 | FC1E24861C2B10F5009E9908 /* LaunchScreen.storyboard in Resources */, 129 | FC1E24831C2B10F5009E9908 /* Assets.xcassets in Resources */, 130 | FC1E24811C2B10F5009E9908 /* Main.storyboard in Resources */, 131 | ); 132 | runOnlyForDeploymentPostprocessing = 0; 133 | }; 134 | /* End PBXResourcesBuildPhase section */ 135 | 136 | /* Begin PBXSourcesBuildPhase section */ 137 | FC1E24741C2B10F5009E9908 /* Sources */ = { 138 | isa = PBXSourcesBuildPhase; 139 | buildActionMask = 2147483647; 140 | files = ( 141 | FCC472811C31DAD600E8FEEC /* LocationSearchTable.swift in Sources */, 142 | FC1E247E1C2B10F5009E9908 /* ViewController.swift in Sources */, 143 | FC1E247C1C2B10F5009E9908 /* AppDelegate.swift in Sources */, 144 | ); 145 | runOnlyForDeploymentPostprocessing = 0; 146 | }; 147 | /* End PBXSourcesBuildPhase section */ 148 | 149 | /* Begin PBXVariantGroup section */ 150 | FC1E247F1C2B10F5009E9908 /* Main.storyboard */ = { 151 | isa = PBXVariantGroup; 152 | children = ( 153 | FC1E24801C2B10F5009E9908 /* Base */, 154 | ); 155 | name = Main.storyboard; 156 | sourceTree = ""; 157 | }; 158 | FC1E24841C2B10F5009E9908 /* LaunchScreen.storyboard */ = { 159 | isa = PBXVariantGroup; 160 | children = ( 161 | FC1E24851C2B10F5009E9908 /* Base */, 162 | ); 163 | name = LaunchScreen.storyboard; 164 | sourceTree = ""; 165 | }; 166 | /* End PBXVariantGroup section */ 167 | 168 | /* Begin XCBuildConfiguration section */ 169 | FC1E24881C2B10F5009E9908 /* Debug */ = { 170 | isa = XCBuildConfiguration; 171 | buildSettings = { 172 | ALWAYS_SEARCH_USER_PATHS = NO; 173 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 174 | CLANG_CXX_LIBRARY = "libc++"; 175 | CLANG_ENABLE_MODULES = YES; 176 | CLANG_ENABLE_OBJC_ARC = YES; 177 | CLANG_WARN_BOOL_CONVERSION = YES; 178 | CLANG_WARN_CONSTANT_CONVERSION = YES; 179 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 180 | CLANG_WARN_EMPTY_BODY = YES; 181 | CLANG_WARN_ENUM_CONVERSION = YES; 182 | CLANG_WARN_INT_CONVERSION = YES; 183 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 184 | CLANG_WARN_UNREACHABLE_CODE = YES; 185 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 186 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 187 | COPY_PHASE_STRIP = NO; 188 | DEBUG_INFORMATION_FORMAT = dwarf; 189 | ENABLE_STRICT_OBJC_MSGSEND = YES; 190 | ENABLE_TESTABILITY = YES; 191 | GCC_C_LANGUAGE_STANDARD = gnu99; 192 | GCC_DYNAMIC_NO_PIC = NO; 193 | GCC_NO_COMMON_BLOCKS = YES; 194 | GCC_OPTIMIZATION_LEVEL = 0; 195 | GCC_PREPROCESSOR_DEFINITIONS = ( 196 | "DEBUG=1", 197 | "$(inherited)", 198 | ); 199 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 200 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 201 | GCC_WARN_UNDECLARED_SELECTOR = YES; 202 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 203 | GCC_WARN_UNUSED_FUNCTION = YES; 204 | GCC_WARN_UNUSED_VARIABLE = YES; 205 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 206 | MTL_ENABLE_DEBUG_INFO = YES; 207 | ONLY_ACTIVE_ARCH = YES; 208 | SDKROOT = iphoneos; 209 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 210 | TARGETED_DEVICE_FAMILY = "1,2"; 211 | }; 212 | name = Debug; 213 | }; 214 | FC1E24891C2B10F5009E9908 /* Release */ = { 215 | isa = XCBuildConfiguration; 216 | buildSettings = { 217 | ALWAYS_SEARCH_USER_PATHS = NO; 218 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 219 | CLANG_CXX_LIBRARY = "libc++"; 220 | CLANG_ENABLE_MODULES = YES; 221 | CLANG_ENABLE_OBJC_ARC = YES; 222 | CLANG_WARN_BOOL_CONVERSION = YES; 223 | CLANG_WARN_CONSTANT_CONVERSION = YES; 224 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 225 | CLANG_WARN_EMPTY_BODY = YES; 226 | CLANG_WARN_ENUM_CONVERSION = YES; 227 | CLANG_WARN_INT_CONVERSION = YES; 228 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 229 | CLANG_WARN_UNREACHABLE_CODE = YES; 230 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 231 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 232 | COPY_PHASE_STRIP = NO; 233 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 234 | ENABLE_NS_ASSERTIONS = NO; 235 | ENABLE_STRICT_OBJC_MSGSEND = YES; 236 | GCC_C_LANGUAGE_STANDARD = gnu99; 237 | GCC_NO_COMMON_BLOCKS = YES; 238 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 239 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 240 | GCC_WARN_UNDECLARED_SELECTOR = YES; 241 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 242 | GCC_WARN_UNUSED_FUNCTION = YES; 243 | GCC_WARN_UNUSED_VARIABLE = YES; 244 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 245 | MTL_ENABLE_DEBUG_INFO = NO; 246 | SDKROOT = iphoneos; 247 | TARGETED_DEVICE_FAMILY = "1,2"; 248 | VALIDATE_PRODUCT = YES; 249 | }; 250 | name = Release; 251 | }; 252 | FC1E248B1C2B10F5009E9908 /* Debug */ = { 253 | isa = XCBuildConfiguration; 254 | buildSettings = { 255 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 256 | INFOPLIST_FILE = MapKitTutorial/Info.plist; 257 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 258 | PRODUCT_BUNDLE_IDENTIFIER = com.thorntech.MapKitTutorial; 259 | PRODUCT_NAME = "$(TARGET_NAME)"; 260 | SWIFT_VERSION = 2.3; 261 | }; 262 | name = Debug; 263 | }; 264 | FC1E248C1C2B10F5009E9908 /* Release */ = { 265 | isa = XCBuildConfiguration; 266 | buildSettings = { 267 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 268 | INFOPLIST_FILE = MapKitTutorial/Info.plist; 269 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 270 | PRODUCT_BUNDLE_IDENTIFIER = com.thorntech.MapKitTutorial; 271 | PRODUCT_NAME = "$(TARGET_NAME)"; 272 | SWIFT_VERSION = 2.3; 273 | }; 274 | name = Release; 275 | }; 276 | /* End XCBuildConfiguration section */ 277 | 278 | /* Begin XCConfigurationList section */ 279 | FC1E24731C2B10F5009E9908 /* Build configuration list for PBXProject "MapKitTutorial" */ = { 280 | isa = XCConfigurationList; 281 | buildConfigurations = ( 282 | FC1E24881C2B10F5009E9908 /* Debug */, 283 | FC1E24891C2B10F5009E9908 /* Release */, 284 | ); 285 | defaultConfigurationIsVisible = 0; 286 | defaultConfigurationName = Release; 287 | }; 288 | FC1E248A1C2B10F5009E9908 /* Build configuration list for PBXNativeTarget "MapKitTutorial" */ = { 289 | isa = XCConfigurationList; 290 | buildConfigurations = ( 291 | FC1E248B1C2B10F5009E9908 /* Debug */, 292 | FC1E248C1C2B10F5009E9908 /* Release */, 293 | ); 294 | defaultConfigurationIsVisible = 0; 295 | defaultConfigurationName = Release; 296 | }; 297 | /* End XCConfigurationList section */ 298 | }; 299 | rootObject = FC1E24701C2B10F5009E9908 /* Project object */; 300 | } 301 | -------------------------------------------------------------------------------- /MapKitTutorial.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /MapKitTutorial.xcodeproj/project.xcworkspace/xcuserdata/robertchen.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThornTechPublic/MapKitTutorial/725fa57cd0e50e9234696c20fdeff54611f62c41/MapKitTutorial.xcodeproj/project.xcworkspace/xcuserdata/robertchen.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /MapKitTutorial.xcodeproj/xcuserdata/robertchen.xcuserdatad/xcschemes/MapKitTutorial.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /MapKitTutorial.xcodeproj/xcuserdata/robertchen.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | MapKitTutorial.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | FC1E24771C2B10F5009E9908 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /MapKitTutorial/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // MapKitTutorial 4 | // 5 | // Created by Robert Chen on 12/23/15. 6 | // Copyright © 2015 Thorn Technologies. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(application: UIApplication) { 23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 24 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(application: UIApplication) { 28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(application: UIApplication) { 33 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(application: UIApplication) { 37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 38 | } 39 | 40 | func applicationWillTerminate(application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /MapKitTutorial/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "83.5x83.5", 66 | "scale" : "2x" 67 | } 68 | ], 69 | "info" : { 70 | "version" : 1, 71 | "author" : "xcode" 72 | } 73 | } -------------------------------------------------------------------------------- /MapKitTutorial/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /MapKitTutorial/Assets.xcassets/car.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "fa-car_30_0_000000_none.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "fa-car_60_0_000000_none.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "fa-car_90_0_000000_none.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /MapKitTutorial/Assets.xcassets/car.imageset/fa-car_30_0_000000_none.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThornTechPublic/MapKitTutorial/725fa57cd0e50e9234696c20fdeff54611f62c41/MapKitTutorial/Assets.xcassets/car.imageset/fa-car_30_0_000000_none.png -------------------------------------------------------------------------------- /MapKitTutorial/Assets.xcassets/car.imageset/fa-car_60_0_000000_none.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThornTechPublic/MapKitTutorial/725fa57cd0e50e9234696c20fdeff54611f62c41/MapKitTutorial/Assets.xcassets/car.imageset/fa-car_60_0_000000_none.png -------------------------------------------------------------------------------- /MapKitTutorial/Assets.xcassets/car.imageset/fa-car_90_0_000000_none.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThornTechPublic/MapKitTutorial/725fa57cd0e50e9234696c20fdeff54611f62c41/MapKitTutorial/Assets.xcassets/car.imageset/fa-car_90_0_000000_none.png -------------------------------------------------------------------------------- /MapKitTutorial/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /MapKitTutorial/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 67 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | -------------------------------------------------------------------------------- /MapKitTutorial/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | NSLocationWhenInUseUsageDescription 6 | This tutorial wants to use your location 7 | CFBundleDevelopmentRegion 8 | en 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UIRequiredDeviceCapabilities 32 | 33 | armv7 34 | 35 | UISupportedInterfaceOrientations 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationLandscapeLeft 39 | UIInterfaceOrientationLandscapeRight 40 | 41 | UISupportedInterfaceOrientations~ipad 42 | 43 | UIInterfaceOrientationPortrait 44 | UIInterfaceOrientationPortraitUpsideDown 45 | UIInterfaceOrientationLandscapeLeft 46 | UIInterfaceOrientationLandscapeRight 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /MapKitTutorial/LocationSearchTable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LocationSearchTable.swift 3 | // MapKitTutorial 4 | // 5 | // Created by Robert Chen on 12/28/15. 6 | // Copyright © 2015 Thorn Technologies. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import MapKit 11 | 12 | class LocationSearchTable: UITableViewController { 13 | 14 | 15 | weak var handleMapSearchDelegate: HandleMapSearch? 16 | var matchingItems: [MKMapItem] = [] 17 | var mapView: MKMapView? 18 | 19 | 20 | func parseAddress(selectedItem:MKPlacemark) -> String { 21 | 22 | // put a space between "4" and "Melrose Place" 23 | let firstSpace = (selectedItem.subThoroughfare != nil && 24 | selectedItem.thoroughfare != nil) ? " " : "" 25 | 26 | // put a comma between street and city/state 27 | let comma = (selectedItem.subThoroughfare != nil || selectedItem.thoroughfare != nil) && 28 | (selectedItem.subAdministrativeArea != nil || selectedItem.administrativeArea != nil) ? ", " : "" 29 | 30 | // put a space between "Washington" and "DC" 31 | let secondSpace = (selectedItem.subAdministrativeArea != nil && 32 | selectedItem.administrativeArea != nil) ? " " : "" 33 | 34 | let addressLine = String( 35 | format:"%@%@%@%@%@%@%@", 36 | // street number 37 | selectedItem.subThoroughfare ?? "", 38 | firstSpace, 39 | // street name 40 | selectedItem.thoroughfare ?? "", 41 | comma, 42 | // city 43 | selectedItem.locality ?? "", 44 | secondSpace, 45 | // state 46 | selectedItem.administrativeArea ?? "" 47 | ) 48 | 49 | return addressLine 50 | } 51 | 52 | } 53 | 54 | extension LocationSearchTable : UISearchResultsUpdating { 55 | 56 | func updateSearchResultsForSearchController(searchController: UISearchController) { 57 | guard let mapView = mapView, 58 | let searchBarText = searchController.searchBar.text else { return } 59 | 60 | let request = MKLocalSearchRequest() 61 | request.naturalLanguageQuery = searchBarText 62 | request.region = mapView.region 63 | let search = MKLocalSearch(request: request) 64 | 65 | search.startWithCompletionHandler { response, _ in 66 | guard let response = response else { 67 | return 68 | } 69 | self.matchingItems = response.mapItems 70 | self.tableView.reloadData() 71 | } 72 | 73 | } 74 | 75 | } 76 | 77 | extension LocationSearchTable { 78 | 79 | override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 80 | return matchingItems.count 81 | } 82 | 83 | override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 84 | let cell = tableView.dequeueReusableCellWithIdentifier("cell")! 85 | let selectedItem = matchingItems[indexPath.row].placemark 86 | cell.textLabel?.text = selectedItem.name 87 | cell.detailTextLabel?.text = parseAddress(selectedItem) 88 | return cell 89 | } 90 | 91 | } 92 | 93 | extension LocationSearchTable { 94 | 95 | override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { 96 | let selectedItem = matchingItems[indexPath.row].placemark 97 | handleMapSearchDelegate?.dropPinZoomIn(selectedItem) 98 | dismissViewControllerAnimated(true, completion: nil) 99 | } 100 | 101 | } -------------------------------------------------------------------------------- /MapKitTutorial/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // MapKitTutorial 4 | // 5 | // Created by Robert Chen on 12/23/15. 6 | // Copyright © 2015 Thorn Technologies. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import MapKit 11 | 12 | protocol HandleMapSearch: class { 13 | func dropPinZoomIn(placemark:MKPlacemark) 14 | } 15 | 16 | class ViewController: UIViewController { 17 | 18 | var selectedPin: MKPlacemark? 19 | var resultSearchController: UISearchController! 20 | 21 | let locationManager = CLLocationManager() 22 | 23 | @IBOutlet weak var mapView: MKMapView! 24 | 25 | 26 | override func viewDidLoad() { 27 | super.viewDidLoad() 28 | 29 | locationManager.delegate = self 30 | locationManager.desiredAccuracy = kCLLocationAccuracyBest 31 | locationManager.requestWhenInUseAuthorization() 32 | locationManager.requestLocation() 33 | let locationSearchTable = storyboard!.instantiateViewControllerWithIdentifier("LocationSearchTable") as! LocationSearchTable 34 | resultSearchController = UISearchController(searchResultsController: locationSearchTable) 35 | resultSearchController.searchResultsUpdater = locationSearchTable 36 | let searchBar = resultSearchController!.searchBar 37 | searchBar.sizeToFit() 38 | searchBar.placeholder = "Search for places" 39 | navigationItem.titleView = resultSearchController?.searchBar 40 | resultSearchController.hidesNavigationBarDuringPresentation = false 41 | resultSearchController.dimsBackgroundDuringPresentation = true 42 | definesPresentationContext = true 43 | locationSearchTable.mapView = mapView 44 | locationSearchTable.handleMapSearchDelegate = self 45 | 46 | } 47 | 48 | func getDirections(){ 49 | guard let selectedPin = selectedPin else { return } 50 | let mapItem = MKMapItem(placemark: selectedPin) 51 | let launchOptions = [MKLaunchOptionsDirectionsModeKey: MKLaunchOptionsDirectionsModeDriving] 52 | mapItem.openInMapsWithLaunchOptions(launchOptions) 53 | } 54 | } 55 | 56 | extension ViewController : CLLocationManagerDelegate { 57 | 58 | func locationManager(manager: CLLocationManager, didChangeAuthorizationStatus status: CLAuthorizationStatus) { 59 | if status == .AuthorizedWhenInUse { 60 | locationManager.requestLocation() 61 | } 62 | } 63 | 64 | func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { 65 | guard let location = locations.first else { return } 66 | let span = MKCoordinateSpanMake(0.05, 0.05) 67 | let region = MKCoordinateRegion(center: location.coordinate, span: span) 68 | mapView.setRegion(region, animated: true) 69 | } 70 | 71 | func locationManager(manager: CLLocationManager, didFailWithError error: NSError) { 72 | print("error:: \(error)") 73 | } 74 | 75 | } 76 | 77 | extension ViewController: HandleMapSearch { 78 | 79 | func dropPinZoomIn(placemark: MKPlacemark){ 80 | // cache the pin 81 | selectedPin = placemark 82 | // clear existing pins 83 | mapView.removeAnnotations(mapView.annotations) 84 | let annotation = MKPointAnnotation() 85 | annotation.coordinate = placemark.coordinate 86 | annotation.title = placemark.name 87 | 88 | if let city = placemark.locality, 89 | let state = placemark.administrativeArea { 90 | annotation.subtitle = "\(city) \(state)" 91 | } 92 | 93 | mapView.addAnnotation(annotation) 94 | let span = MKCoordinateSpanMake(0.05, 0.05) 95 | let region = MKCoordinateRegionMake(placemark.coordinate, span) 96 | mapView.setRegion(region, animated: true) 97 | } 98 | 99 | } 100 | 101 | extension ViewController : MKMapViewDelegate { 102 | 103 | func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView?{ 104 | 105 | guard !(annotation is MKUserLocation) else { return nil } 106 | let reuseId = "pin" 107 | var pinView = mapView.dequeueReusableAnnotationViewWithIdentifier(reuseId) as? MKPinAnnotationView 108 | if pinView == nil { 109 | pinView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: reuseId) 110 | } 111 | pinView?.pinTintColor = UIColor.orangeColor() 112 | pinView?.canShowCallout = true 113 | let smallSquare = CGSize(width: 30, height: 30) 114 | let button = UIButton(frame: CGRect(origin: CGPointZero, size: smallSquare)) 115 | button.setBackgroundImage(UIImage(named: "car"), forState: .Normal) 116 | button.addTarget(self, action: #selector(ViewController.getDirections), forControlEvents: .TouchUpInside) 117 | pinView?.leftCalloutAccessoryView = button 118 | 119 | return pinView 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MapKitTutorial 2 | 3 | How to search for location and display results using Apple’s MapKit 4 | 5 | ## License 6 | 7 | This is released under the MIT license. See LICENSE for details. 8 | --------------------------------------------------------------------------------