├── IMG_1996.PNG ├── MapNavigationDemo.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ ├── gm2.xcuserdatad │ │ └── UserInterfaceState.xcuserstate │ │ └── wangcanhui.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ ├── gm2.xcuserdatad │ └── xcschemes │ │ ├── MapNavigationDemo.xcscheme │ │ └── xcschememanagement.plist │ └── wangcanhui.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── MapNavigationDemo.xcscheme │ └── xcschememanagement.plist ├── MapNavigationDemo ├── AppDelegate.swift ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── CHNavigationTool.swift ├── Info.plist └── ViewController.swift └── README.md /IMG_1996.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangCanHui/MapNavigationDemo/c3d6c210b3c48cd2ca3d439bdc5b35877f898231/IMG_1996.PNG -------------------------------------------------------------------------------- /MapNavigationDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 6F220D6A1D8D180900B1BB01 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F220D691D8D180900B1BB01 /* AppDelegate.swift */; }; 11 | 6F220D6C1D8D180900B1BB01 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F220D6B1D8D180900B1BB01 /* ViewController.swift */; }; 12 | 6F220D6F1D8D180900B1BB01 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6F220D6D1D8D180900B1BB01 /* Main.storyboard */; }; 13 | 6F220D711D8D180900B1BB01 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6F220D701D8D180900B1BB01 /* Assets.xcassets */; }; 14 | 6F220D741D8D180900B1BB01 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6F220D721D8D180900B1BB01 /* LaunchScreen.storyboard */; }; 15 | 6F220D7C1D8D181C00B1BB01 /* CHNavigationTool.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F220D7B1D8D181C00B1BB01 /* CHNavigationTool.swift */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXFileReference section */ 19 | 6F220D661D8D180900B1BB01 /* MapNavigationDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MapNavigationDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 20 | 6F220D691D8D180900B1BB01 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 21 | 6F220D6B1D8D180900B1BB01 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 22 | 6F220D6E1D8D180900B1BB01 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 23 | 6F220D701D8D180900B1BB01 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 24 | 6F220D731D8D180900B1BB01 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 25 | 6F220D751D8D180900B1BB01 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 26 | 6F220D7B1D8D181C00B1BB01 /* CHNavigationTool.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CHNavigationTool.swift; sourceTree = ""; }; 27 | /* End PBXFileReference section */ 28 | 29 | /* Begin PBXFrameworksBuildPhase section */ 30 | 6F220D631D8D180900B1BB01 /* Frameworks */ = { 31 | isa = PBXFrameworksBuildPhase; 32 | buildActionMask = 2147483647; 33 | files = ( 34 | ); 35 | runOnlyForDeploymentPostprocessing = 0; 36 | }; 37 | /* End PBXFrameworksBuildPhase section */ 38 | 39 | /* Begin PBXGroup section */ 40 | 6F220D5D1D8D180900B1BB01 = { 41 | isa = PBXGroup; 42 | children = ( 43 | 6F220D681D8D180900B1BB01 /* MapNavigationDemo */, 44 | 6F220D671D8D180900B1BB01 /* Products */, 45 | ); 46 | sourceTree = ""; 47 | }; 48 | 6F220D671D8D180900B1BB01 /* Products */ = { 49 | isa = PBXGroup; 50 | children = ( 51 | 6F220D661D8D180900B1BB01 /* MapNavigationDemo.app */, 52 | ); 53 | name = Products; 54 | sourceTree = ""; 55 | }; 56 | 6F220D681D8D180900B1BB01 /* MapNavigationDemo */ = { 57 | isa = PBXGroup; 58 | children = ( 59 | 6F220D691D8D180900B1BB01 /* AppDelegate.swift */, 60 | 6F220D6B1D8D180900B1BB01 /* ViewController.swift */, 61 | 6F220D7B1D8D181C00B1BB01 /* CHNavigationTool.swift */, 62 | 6F220D6D1D8D180900B1BB01 /* Main.storyboard */, 63 | 6F220D701D8D180900B1BB01 /* Assets.xcassets */, 64 | 6F220D721D8D180900B1BB01 /* LaunchScreen.storyboard */, 65 | 6F220D751D8D180900B1BB01 /* Info.plist */, 66 | ); 67 | path = MapNavigationDemo; 68 | sourceTree = ""; 69 | }; 70 | /* End PBXGroup section */ 71 | 72 | /* Begin PBXNativeTarget section */ 73 | 6F220D651D8D180900B1BB01 /* MapNavigationDemo */ = { 74 | isa = PBXNativeTarget; 75 | buildConfigurationList = 6F220D781D8D180900B1BB01 /* Build configuration list for PBXNativeTarget "MapNavigationDemo" */; 76 | buildPhases = ( 77 | 6F220D621D8D180900B1BB01 /* Sources */, 78 | 6F220D631D8D180900B1BB01 /* Frameworks */, 79 | 6F220D641D8D180900B1BB01 /* Resources */, 80 | ); 81 | buildRules = ( 82 | ); 83 | dependencies = ( 84 | ); 85 | name = MapNavigationDemo; 86 | productName = MapNavigationDemo; 87 | productReference = 6F220D661D8D180900B1BB01 /* MapNavigationDemo.app */; 88 | productType = "com.apple.product-type.application"; 89 | }; 90 | /* End PBXNativeTarget section */ 91 | 92 | /* Begin PBXProject section */ 93 | 6F220D5E1D8D180900B1BB01 /* Project object */ = { 94 | isa = PBXProject; 95 | attributes = { 96 | LastSwiftUpdateCheck = 0730; 97 | LastUpgradeCheck = 0800; 98 | ORGANIZATIONNAME = "王灿辉"; 99 | TargetAttributes = { 100 | 6F220D651D8D180900B1BB01 = { 101 | CreatedOnToolsVersion = 7.3.1; 102 | DevelopmentTeam = 2L9ZWE43QB; 103 | LastSwiftMigration = 0800; 104 | ProvisioningStyle = Automatic; 105 | }; 106 | }; 107 | }; 108 | buildConfigurationList = 6F220D611D8D180900B1BB01 /* Build configuration list for PBXProject "MapNavigationDemo" */; 109 | compatibilityVersion = "Xcode 3.2"; 110 | developmentRegion = English; 111 | hasScannedForEncodings = 0; 112 | knownRegions = ( 113 | en, 114 | Base, 115 | ); 116 | mainGroup = 6F220D5D1D8D180900B1BB01; 117 | productRefGroup = 6F220D671D8D180900B1BB01 /* Products */; 118 | projectDirPath = ""; 119 | projectRoot = ""; 120 | targets = ( 121 | 6F220D651D8D180900B1BB01 /* MapNavigationDemo */, 122 | ); 123 | }; 124 | /* End PBXProject section */ 125 | 126 | /* Begin PBXResourcesBuildPhase section */ 127 | 6F220D641D8D180900B1BB01 /* Resources */ = { 128 | isa = PBXResourcesBuildPhase; 129 | buildActionMask = 2147483647; 130 | files = ( 131 | 6F220D741D8D180900B1BB01 /* LaunchScreen.storyboard in Resources */, 132 | 6F220D711D8D180900B1BB01 /* Assets.xcassets in Resources */, 133 | 6F220D6F1D8D180900B1BB01 /* Main.storyboard in Resources */, 134 | ); 135 | runOnlyForDeploymentPostprocessing = 0; 136 | }; 137 | /* End PBXResourcesBuildPhase section */ 138 | 139 | /* Begin PBXSourcesBuildPhase section */ 140 | 6F220D621D8D180900B1BB01 /* Sources */ = { 141 | isa = PBXSourcesBuildPhase; 142 | buildActionMask = 2147483647; 143 | files = ( 144 | 6F220D6C1D8D180900B1BB01 /* ViewController.swift in Sources */, 145 | 6F220D6A1D8D180900B1BB01 /* AppDelegate.swift in Sources */, 146 | 6F220D7C1D8D181C00B1BB01 /* CHNavigationTool.swift in Sources */, 147 | ); 148 | runOnlyForDeploymentPostprocessing = 0; 149 | }; 150 | /* End PBXSourcesBuildPhase section */ 151 | 152 | /* Begin PBXVariantGroup section */ 153 | 6F220D6D1D8D180900B1BB01 /* Main.storyboard */ = { 154 | isa = PBXVariantGroup; 155 | children = ( 156 | 6F220D6E1D8D180900B1BB01 /* Base */, 157 | ); 158 | name = Main.storyboard; 159 | sourceTree = ""; 160 | }; 161 | 6F220D721D8D180900B1BB01 /* LaunchScreen.storyboard */ = { 162 | isa = PBXVariantGroup; 163 | children = ( 164 | 6F220D731D8D180900B1BB01 /* Base */, 165 | ); 166 | name = LaunchScreen.storyboard; 167 | sourceTree = ""; 168 | }; 169 | /* End PBXVariantGroup section */ 170 | 171 | /* Begin XCBuildConfiguration section */ 172 | 6F220D761D8D180900B1BB01 /* Debug */ = { 173 | isa = XCBuildConfiguration; 174 | buildSettings = { 175 | ALWAYS_SEARCH_USER_PATHS = NO; 176 | CLANG_ANALYZER_NONNULL = YES; 177 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 178 | CLANG_CXX_LIBRARY = "libc++"; 179 | CLANG_ENABLE_MODULES = YES; 180 | CLANG_ENABLE_OBJC_ARC = YES; 181 | CLANG_WARN_BOOL_CONVERSION = YES; 182 | CLANG_WARN_CONSTANT_CONVERSION = YES; 183 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 184 | CLANG_WARN_EMPTY_BODY = YES; 185 | CLANG_WARN_ENUM_CONVERSION = YES; 186 | CLANG_WARN_INFINITE_RECURSION = YES; 187 | CLANG_WARN_INT_CONVERSION = YES; 188 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 189 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 190 | CLANG_WARN_UNREACHABLE_CODE = YES; 191 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 192 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 193 | COPY_PHASE_STRIP = NO; 194 | DEBUG_INFORMATION_FORMAT = dwarf; 195 | ENABLE_STRICT_OBJC_MSGSEND = YES; 196 | ENABLE_TESTABILITY = YES; 197 | GCC_C_LANGUAGE_STANDARD = gnu99; 198 | GCC_DYNAMIC_NO_PIC = NO; 199 | GCC_NO_COMMON_BLOCKS = YES; 200 | GCC_OPTIMIZATION_LEVEL = 0; 201 | GCC_PREPROCESSOR_DEFINITIONS = ( 202 | "DEBUG=1", 203 | "$(inherited)", 204 | ); 205 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 206 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 207 | GCC_WARN_UNDECLARED_SELECTOR = YES; 208 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 209 | GCC_WARN_UNUSED_FUNCTION = YES; 210 | GCC_WARN_UNUSED_VARIABLE = YES; 211 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 212 | MTL_ENABLE_DEBUG_INFO = YES; 213 | ONLY_ACTIVE_ARCH = YES; 214 | SDKROOT = iphoneos; 215 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 216 | TARGETED_DEVICE_FAMILY = "1,2"; 217 | }; 218 | name = Debug; 219 | }; 220 | 6F220D771D8D180900B1BB01 /* Release */ = { 221 | isa = XCBuildConfiguration; 222 | buildSettings = { 223 | ALWAYS_SEARCH_USER_PATHS = NO; 224 | CLANG_ANALYZER_NONNULL = YES; 225 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 226 | CLANG_CXX_LIBRARY = "libc++"; 227 | CLANG_ENABLE_MODULES = YES; 228 | CLANG_ENABLE_OBJC_ARC = YES; 229 | CLANG_WARN_BOOL_CONVERSION = YES; 230 | CLANG_WARN_CONSTANT_CONVERSION = YES; 231 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 232 | CLANG_WARN_EMPTY_BODY = YES; 233 | CLANG_WARN_ENUM_CONVERSION = YES; 234 | CLANG_WARN_INFINITE_RECURSION = YES; 235 | CLANG_WARN_INT_CONVERSION = YES; 236 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 237 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 238 | CLANG_WARN_UNREACHABLE_CODE = YES; 239 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 240 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 241 | COPY_PHASE_STRIP = NO; 242 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 243 | ENABLE_NS_ASSERTIONS = NO; 244 | ENABLE_STRICT_OBJC_MSGSEND = YES; 245 | GCC_C_LANGUAGE_STANDARD = gnu99; 246 | GCC_NO_COMMON_BLOCKS = YES; 247 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 248 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 249 | GCC_WARN_UNDECLARED_SELECTOR = YES; 250 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 251 | GCC_WARN_UNUSED_FUNCTION = YES; 252 | GCC_WARN_UNUSED_VARIABLE = YES; 253 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 254 | MTL_ENABLE_DEBUG_INFO = NO; 255 | SDKROOT = iphoneos; 256 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 257 | TARGETED_DEVICE_FAMILY = "1,2"; 258 | VALIDATE_PRODUCT = YES; 259 | }; 260 | name = Release; 261 | }; 262 | 6F220D791D8D180900B1BB01 /* Debug */ = { 263 | isa = XCBuildConfiguration; 264 | buildSettings = { 265 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 266 | CODE_SIGN_IDENTITY = "iPhone Developer"; 267 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 268 | DEVELOPMENT_TEAM = 2L9ZWE43QB; 269 | INFOPLIST_FILE = MapNavigationDemo/Info.plist; 270 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 271 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 272 | PRODUCT_BUNDLE_IDENTIFIER = cn.wangCanHui.MapNavigationDemo; 273 | PRODUCT_NAME = "$(TARGET_NAME)"; 274 | SWIFT_VERSION = 3.0; 275 | }; 276 | name = Debug; 277 | }; 278 | 6F220D7A1D8D180900B1BB01 /* Release */ = { 279 | isa = XCBuildConfiguration; 280 | buildSettings = { 281 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 282 | CODE_SIGN_IDENTITY = "iPhone Developer"; 283 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 284 | DEVELOPMENT_TEAM = 2L9ZWE43QB; 285 | INFOPLIST_FILE = MapNavigationDemo/Info.plist; 286 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 287 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 288 | PRODUCT_BUNDLE_IDENTIFIER = cn.wangCanHui.MapNavigationDemo; 289 | PRODUCT_NAME = "$(TARGET_NAME)"; 290 | SWIFT_VERSION = 3.0; 291 | }; 292 | name = Release; 293 | }; 294 | /* End XCBuildConfiguration section */ 295 | 296 | /* Begin XCConfigurationList section */ 297 | 6F220D611D8D180900B1BB01 /* Build configuration list for PBXProject "MapNavigationDemo" */ = { 298 | isa = XCConfigurationList; 299 | buildConfigurations = ( 300 | 6F220D761D8D180900B1BB01 /* Debug */, 301 | 6F220D771D8D180900B1BB01 /* Release */, 302 | ); 303 | defaultConfigurationIsVisible = 0; 304 | defaultConfigurationName = Release; 305 | }; 306 | 6F220D781D8D180900B1BB01 /* Build configuration list for PBXNativeTarget "MapNavigationDemo" */ = { 307 | isa = XCConfigurationList; 308 | buildConfigurations = ( 309 | 6F220D791D8D180900B1BB01 /* Debug */, 310 | 6F220D7A1D8D180900B1BB01 /* Release */, 311 | ); 312 | defaultConfigurationIsVisible = 0; 313 | defaultConfigurationName = Release; 314 | }; 315 | /* End XCConfigurationList section */ 316 | }; 317 | rootObject = 6F220D5E1D8D180900B1BB01 /* Project object */; 318 | } 319 | -------------------------------------------------------------------------------- /MapNavigationDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /MapNavigationDemo.xcodeproj/project.xcworkspace/xcuserdata/gm2.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangCanHui/MapNavigationDemo/c3d6c210b3c48cd2ca3d439bdc5b35877f898231/MapNavigationDemo.xcodeproj/project.xcworkspace/xcuserdata/gm2.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /MapNavigationDemo.xcodeproj/project.xcworkspace/xcuserdata/wangcanhui.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangCanHui/MapNavigationDemo/c3d6c210b3c48cd2ca3d439bdc5b35877f898231/MapNavigationDemo.xcodeproj/project.xcworkspace/xcuserdata/wangcanhui.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /MapNavigationDemo.xcodeproj/xcuserdata/gm2.xcuserdatad/xcschemes/MapNavigationDemo.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 | -------------------------------------------------------------------------------- /MapNavigationDemo.xcodeproj/xcuserdata/gm2.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | MapNavigationDemo.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 6F220D651D8D180900B1BB01 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /MapNavigationDemo.xcodeproj/xcuserdata/wangcanhui.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /MapNavigationDemo.xcodeproj/xcuserdata/wangcanhui.xcuserdatad/xcschemes/MapNavigationDemo.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 | -------------------------------------------------------------------------------- /MapNavigationDemo.xcodeproj/xcuserdata/wangcanhui.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | MapNavigationDemo.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 6F220D651D8D180900B1BB01 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /MapNavigationDemo/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // MapNavigationDemo 4 | // 5 | // Created by 王灿辉 on 16/9/17. 6 | // Copyright © 2016年 王灿辉. 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: [UIApplicationLaunchOptionsKey: Any]?) -> 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 | -------------------------------------------------------------------------------- /MapNavigationDemo/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 | } -------------------------------------------------------------------------------- /MapNavigationDemo/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 | -------------------------------------------------------------------------------- /MapNavigationDemo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /MapNavigationDemo/CHNavigationTool.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CHNavigationTool.swift 3 | // carService 4 | // 5 | // Created by GMobile No.2 on 16/5/25. 6 | // Copyright © 2016年 王灿辉. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import MapKit 11 | 12 | /// 导航工具类 13 | class CHNavigationTool: NSObject,UIActionSheetDelegate { 14 | fileprivate var currentLocation : CLLocation! 15 | fileprivate var toLocation : CLLocation! 16 | fileprivate var viewController : UIViewController! 17 | fileprivate var title : String! 18 | fileprivate var isSetupBaiduMap : Bool = false 19 | fileprivate var isSetupGaoDeMap : Bool = false 20 | /// 创建单例 21 | static let sharedInstance: CHNavigationTool = CHNavigationTool() 22 | 23 | override init() { 24 | super.init() 25 | } 26 | 27 | /** 28 | 构造函数 29 | currentLocation : 当前位置 (百度地图经纬度) 30 | toLocation : 目的地 (百度地图经纬度) 31 | viewController : 显示到的控制器 32 | title : 弹出窗口的标题 33 | */ 34 | init(currentLocation:CLLocation,toLocation:CLLocation,viewController:UIViewController,title:String) { 35 | self.currentLocation = currentLocation 36 | self.toLocation = toLocation 37 | self.viewController = viewController 38 | self.title = title 39 | super.init() 40 | } 41 | 42 | /// 显示导航视图 43 | func showNavigationView() { 44 | // 是否已安装百度地图 45 | isSetupBaiduMap = UIApplication.shared.canOpenURL(URL(string:"baidumap://map/")!) ? true : false 46 | // 是否已安装高德地图 47 | isSetupGaoDeMap = UIApplication.shared.canOpenURL(URL(string:"iosamap://")!) ? true : false 48 | 49 | var alertVC : UIAlertController! 50 | if UIDevice.current.model != "iPhone" { 51 | alertVC = UIAlertController(title: title, message: nil, preferredStyle: UIAlertControllerStyle.alert) 52 | }else{ 53 | alertVC = UIAlertController(title: title, message: nil, preferredStyle: UIAlertControllerStyle.actionSheet) 54 | } 55 | 56 | let toCoordinate = coordinateTransform(toLocation.coordinate) 57 | 58 | alertVC.addAction(UIAlertAction(title: "使用苹果自带地图导航", style: UIAlertActionStyle.default) { (_) in 59 | // 苹果自身地图导航 60 | let toItem = MKMapItem(placemark: MKPlacemark(coordinate: toCoordinate, addressDictionary: nil)) 61 | let items = [toItem] 62 | let options = [MKLaunchOptionsDirectionsModeKey:MKLaunchOptionsDirectionsModeDriving,MKLaunchOptionsShowsTrafficKey:"\(true)"] 63 | MKMapItem.openMaps(with: items, launchOptions: options) 64 | }) 65 | 66 | if isSetupGaoDeMap { 67 | alertVC.addAction(UIAlertAction(title: "使用高德地图导航", style: UIAlertActionStyle.default) { (_) in 68 | // 高德地图导航 69 | self.setupGaoDeMap(toCoordinate) 70 | }) 71 | 72 | } 73 | 74 | if isSetupBaiduMap { 75 | alertVC.addAction(UIAlertAction(title: "使用百度地图导航", style: UIAlertActionStyle.default) { (_) in 76 | // 百度地图导航 77 | self.setupBaiduMap(self.toLocation.coordinate) 78 | }) 79 | } 80 | alertVC.addAction(UIAlertAction(title: "取消", style: UIAlertActionStyle.cancel) { (_) in 81 | self.viewController.dismiss(animated: true, completion: nil) 82 | }) 83 | self.viewController.present(alertVC, animated: true, completion: nil) 84 | 85 | } 86 | 87 | // 调用高德地图 88 | fileprivate func setupGaoDeMap(_ toCoordinate:CLLocationCoordinate2D){ 89 | // 调用地图路径规划的字符串 90 | var urlStr = "iosamap://path?sourceApplication=MapNavigationDemo&backScheme=cn.wangCanHui.MapNavigationDemo" 91 | urlStr += "&dlat=" + "\(toCoordinate.latitude)" + "&dlon=" + "\(toCoordinate.longitude)" + "&dev=0&m=3&t=0" 92 | 93 | urlStr = urlStr.addingPercentEncoding(withAllowedCharacters: CharacterSet.urlQueryAllowed)! 94 | let url = URL(string: urlStr)! 95 | 96 | // 手机安装有高德地图app 97 | if (UIApplication.shared.canOpenURL(url)) { 98 | UIApplication.shared.openURL(url) 99 | } 100 | } 101 | // 调用百度地图 102 | fileprivate func setupBaiduMap(_ toCoordinate:CLLocationCoordinate2D){ 103 | // 调用地图路径规划的字符串 104 | var urlStr = "baidumap://map/direction?origin=" + "\(currentLocation.coordinate.latitude)" + ",\(currentLocation.coordinate.longitude)" 105 | urlStr += "&destination=" + "\(toCoordinate.latitude)" + ",\(toCoordinate.longitude)" + "&mode=driving" 106 | let url = URL(string: urlStr)! 107 | 108 | // 手机安装有百度地图app 109 | if (UIApplication.shared.canOpenURL(url)) { 110 | UIApplication.shared.openURL(url) 111 | } 112 | } 113 | /// 百度地图经纬度转高德、苹果 114 | func coordinateTransform(_ coordinate:CLLocationCoordinate2D) -> CLLocationCoordinate2D { 115 | // 国测局GCJ-02坐标体系(谷歌、高德、腾讯),百度坐标BD-09体系 116 | // 将 BD-09 坐标转换成 GCJ-02 坐标 117 | let x_pi = 3.14159265358979324 * 3000.0 / 180.0 118 | let x = coordinate.longitude - 0.0065 119 | let y = coordinate.latitude - 0.006 120 | let z = sqrt(x*x + y*y) - 0.00002*sin(y * x_pi) 121 | let theta = atan2(y,x) - 0.000003*cos(x * x_pi) 122 | let gg_lat = z*sin(theta) 123 | let gg_lon = z*cos(theta) 124 | return CLLocationCoordinate2DMake(gg_lat, gg_lon) 125 | } 126 | 127 | } 128 | -------------------------------------------------------------------------------- /MapNavigationDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleURLTypes 22 | 23 | 24 | CFBundleTypeRole 25 | Editor 26 | CFBundleURLName 27 | 28 | CFBundleURLSchemes 29 | 30 | cn.wangCanHui.MapNavigationDemo 31 | 32 | 33 | 34 | CFBundleVersion 35 | 1 36 | LSApplicationQueriesSchemes 37 | 38 | iosamap 39 | baidumap 40 | 41 | LSRequiresIPhoneOS 42 | 43 | UILaunchStoryboardName 44 | LaunchScreen 45 | UIMainStoryboardFile 46 | Main 47 | UIRequiredDeviceCapabilities 48 | 49 | armv7 50 | 51 | UISupportedInterfaceOrientations 52 | 53 | UIInterfaceOrientationPortrait 54 | UIInterfaceOrientationLandscapeLeft 55 | UIInterfaceOrientationLandscapeRight 56 | 57 | UISupportedInterfaceOrientations~ipad 58 | 59 | UIInterfaceOrientationPortrait 60 | UIInterfaceOrientationPortraitUpsideDown 61 | UIInterfaceOrientationLandscapeLeft 62 | UIInterfaceOrientationLandscapeRight 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /MapNavigationDemo/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // MapNavigationDemo 4 | // 5 | // Created by 王灿辉 on 16/9/17. 6 | // Copyright © 2016年 王灿辉. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import MapKit 11 | 12 | class ViewController: UIViewController { 13 | /// 导航工具类 14 | fileprivate var navTool : CHNavigationTool! 15 | 16 | override func viewDidLoad() { 17 | super.viewDidLoad() 18 | // 注:此方法使用的是百度地图的经纬度 19 | navTool = CHNavigationTool(currentLocation: CLLocation(latitude: 29.56646671,longitude: 106.47713852), toLocation: CLLocation(latitude: 29.697116999999999,longitude: 106.61015999999999), viewController: self, title: "请选择地图"); 20 | 21 | } 22 | 23 | @IBAction func showNavView() { 24 | navTool.showNavigationView() 25 | } 26 | 27 | } 28 | 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MapNavigationDemo 2 | Packaged navigation tools, two lines of code to get the App iOS internal jump third party applications (Baidu, Gao De, Apple) map navigation, the results are shown below:
3 | 封装的导航工具类,两行代码搞定iOS App内部跳转第三方应用(百度、高德、苹果)地图导航,效果图如下所示: 4 | ![image](https://github.com/wangCanHui/MapNavigationDemo/blob/master/IMG_1996.PNG) 5 | --------------------------------------------------------------------------------