├── README.md ├── test.gpx ├── test.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata └── test ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets └── AppIcon.appiconset │ └── Contents.json ├── Base.lproj ├── LaunchScreen.storyboard └── Main.storyboard ├── Info.plist ├── LocationController.h ├── LocationController.m ├── ViewController.h ├── ViewController.m └── main.m /README.md: -------------------------------------------------------------------------------- 1 | # testGPS 2 | 模拟定位:原理通过运行Xcode工程,修改启动工程中的定位,来实现手机模拟定位 3 | 4 | -------------------------------------------------------------------------------- /test.gpx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /test.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 253E17731E34922B00425821 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 253E17721E34922B00425821 /* main.m */; }; 11 | 253E17761E34922B00425821 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 253E17751E34922B00425821 /* AppDelegate.m */; }; 12 | 253E17791E34922B00425821 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 253E17781E34922B00425821 /* ViewController.m */; }; 13 | 253E177C1E34922B00425821 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 253E177A1E34922B00425821 /* Main.storyboard */; }; 14 | 253E177E1E34922B00425821 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 253E177D1E34922B00425821 /* Assets.xcassets */; }; 15 | 253E17811E34922B00425821 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 253E177F1E34922B00425821 /* LaunchScreen.storyboard */; }; 16 | 253E17891E34927900425821 /* test.gpx in Resources */ = {isa = PBXBuildFile; fileRef = 253E17881E34927900425821 /* test.gpx */; }; 17 | 253E178C1E3494C900425821 /* LocationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 253E178B1E3494C900425821 /* LocationController.m */; }; 18 | 25D13322238D10EB008E6639 /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 25D13321238D10EB008E6639 /* CoreLocation.framework */; }; 19 | /* End PBXBuildFile section */ 20 | 21 | /* Begin PBXFileReference section */ 22 | 253E176E1E34922B00425821 /* test.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = test.app; sourceTree = BUILT_PRODUCTS_DIR; }; 23 | 253E17721E34922B00425821 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 24 | 253E17741E34922B00425821 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 25 | 253E17751E34922B00425821 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 26 | 253E17771E34922B00425821 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 27 | 253E17781E34922B00425821 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 28 | 253E177B1E34922B00425821 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 29 | 253E177D1E34922B00425821 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 30 | 253E17801E34922B00425821 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 31 | 253E17821E34922B00425821 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 32 | 253E17881E34927900425821 /* test.gpx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = test.gpx; sourceTree = SOURCE_ROOT; }; 33 | 253E178A1E3494C900425821 /* LocationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LocationController.h; sourceTree = ""; }; 34 | 253E178B1E3494C900425821 /* LocationController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LocationController.m; sourceTree = ""; }; 35 | 25D13321238D10EB008E6639 /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = System/Library/Frameworks/CoreLocation.framework; sourceTree = SDKROOT; }; 36 | /* End PBXFileReference section */ 37 | 38 | /* Begin PBXFrameworksBuildPhase section */ 39 | 253E176B1E34922B00425821 /* Frameworks */ = { 40 | isa = PBXFrameworksBuildPhase; 41 | buildActionMask = 2147483647; 42 | files = ( 43 | 25D13322238D10EB008E6639 /* CoreLocation.framework in Frameworks */, 44 | ); 45 | runOnlyForDeploymentPostprocessing = 0; 46 | }; 47 | /* End PBXFrameworksBuildPhase section */ 48 | 49 | /* Begin PBXGroup section */ 50 | 253E17651E34922B00425821 = { 51 | isa = PBXGroup; 52 | children = ( 53 | 253E17701E34922B00425821 /* test */, 54 | 253E176F1E34922B00425821 /* Products */, 55 | 25D13320238D10EB008E6639 /* Frameworks */, 56 | ); 57 | sourceTree = ""; 58 | }; 59 | 253E176F1E34922B00425821 /* Products */ = { 60 | isa = PBXGroup; 61 | children = ( 62 | 253E176E1E34922B00425821 /* test.app */, 63 | ); 64 | name = Products; 65 | sourceTree = ""; 66 | }; 67 | 253E17701E34922B00425821 /* test */ = { 68 | isa = PBXGroup; 69 | children = ( 70 | 253E17741E34922B00425821 /* AppDelegate.h */, 71 | 253E17751E34922B00425821 /* AppDelegate.m */, 72 | 253E17771E34922B00425821 /* ViewController.h */, 73 | 253E17781E34922B00425821 /* ViewController.m */, 74 | 253E17881E34927900425821 /* test.gpx */, 75 | 253E178A1E3494C900425821 /* LocationController.h */, 76 | 253E178B1E3494C900425821 /* LocationController.m */, 77 | 253E177A1E34922B00425821 /* Main.storyboard */, 78 | 253E177D1E34922B00425821 /* Assets.xcassets */, 79 | 253E177F1E34922B00425821 /* LaunchScreen.storyboard */, 80 | 253E17821E34922B00425821 /* Info.plist */, 81 | 253E17711E34922B00425821 /* Supporting Files */, 82 | ); 83 | path = test; 84 | sourceTree = ""; 85 | }; 86 | 253E17711E34922B00425821 /* Supporting Files */ = { 87 | isa = PBXGroup; 88 | children = ( 89 | 253E17721E34922B00425821 /* main.m */, 90 | ); 91 | name = "Supporting Files"; 92 | sourceTree = ""; 93 | }; 94 | 25D13320238D10EB008E6639 /* Frameworks */ = { 95 | isa = PBXGroup; 96 | children = ( 97 | 25D13321238D10EB008E6639 /* CoreLocation.framework */, 98 | ); 99 | name = Frameworks; 100 | sourceTree = ""; 101 | }; 102 | /* End PBXGroup section */ 103 | 104 | /* Begin PBXNativeTarget section */ 105 | 253E176D1E34922B00425821 /* test */ = { 106 | isa = PBXNativeTarget; 107 | buildConfigurationList = 253E17851E34922B00425821 /* Build configuration list for PBXNativeTarget "test" */; 108 | buildPhases = ( 109 | 253E176A1E34922B00425821 /* Sources */, 110 | 253E176B1E34922B00425821 /* Frameworks */, 111 | 253E176C1E34922B00425821 /* Resources */, 112 | ); 113 | buildRules = ( 114 | ); 115 | dependencies = ( 116 | ); 117 | name = test; 118 | productName = test; 119 | productReference = 253E176E1E34922B00425821 /* test.app */; 120 | productType = "com.apple.product-type.application"; 121 | }; 122 | /* End PBXNativeTarget section */ 123 | 124 | /* Begin PBXProject section */ 125 | 253E17661E34922B00425821 /* Project object */ = { 126 | isa = PBXProject; 127 | attributes = { 128 | LastUpgradeCheck = 0820; 129 | ORGANIZATIONNAME = "贾仕琪"; 130 | TargetAttributes = { 131 | 253E176D1E34922B00425821 = { 132 | CreatedOnToolsVersion = 8.2.1; 133 | DevelopmentTeam = 9W2SHLVZPY; 134 | ProvisioningStyle = Automatic; 135 | }; 136 | }; 137 | }; 138 | buildConfigurationList = 253E17691E34922B00425821 /* Build configuration list for PBXProject "test" */; 139 | compatibilityVersion = "Xcode 3.2"; 140 | developmentRegion = English; 141 | hasScannedForEncodings = 0; 142 | knownRegions = ( 143 | English, 144 | en, 145 | Base, 146 | ); 147 | mainGroup = 253E17651E34922B00425821; 148 | productRefGroup = 253E176F1E34922B00425821 /* Products */; 149 | projectDirPath = ""; 150 | projectRoot = ""; 151 | targets = ( 152 | 253E176D1E34922B00425821 /* test */, 153 | ); 154 | }; 155 | /* End PBXProject section */ 156 | 157 | /* Begin PBXResourcesBuildPhase section */ 158 | 253E176C1E34922B00425821 /* Resources */ = { 159 | isa = PBXResourcesBuildPhase; 160 | buildActionMask = 2147483647; 161 | files = ( 162 | 253E17811E34922B00425821 /* LaunchScreen.storyboard in Resources */, 163 | 253E17891E34927900425821 /* test.gpx in Resources */, 164 | 253E177E1E34922B00425821 /* Assets.xcassets in Resources */, 165 | 253E177C1E34922B00425821 /* Main.storyboard in Resources */, 166 | ); 167 | runOnlyForDeploymentPostprocessing = 0; 168 | }; 169 | /* End PBXResourcesBuildPhase section */ 170 | 171 | /* Begin PBXSourcesBuildPhase section */ 172 | 253E176A1E34922B00425821 /* Sources */ = { 173 | isa = PBXSourcesBuildPhase; 174 | buildActionMask = 2147483647; 175 | files = ( 176 | 253E178C1E3494C900425821 /* LocationController.m in Sources */, 177 | 253E17791E34922B00425821 /* ViewController.m in Sources */, 178 | 253E17761E34922B00425821 /* AppDelegate.m in Sources */, 179 | 253E17731E34922B00425821 /* main.m in Sources */, 180 | ); 181 | runOnlyForDeploymentPostprocessing = 0; 182 | }; 183 | /* End PBXSourcesBuildPhase section */ 184 | 185 | /* Begin PBXVariantGroup section */ 186 | 253E177A1E34922B00425821 /* Main.storyboard */ = { 187 | isa = PBXVariantGroup; 188 | children = ( 189 | 253E177B1E34922B00425821 /* Base */, 190 | ); 191 | name = Main.storyboard; 192 | sourceTree = ""; 193 | }; 194 | 253E177F1E34922B00425821 /* LaunchScreen.storyboard */ = { 195 | isa = PBXVariantGroup; 196 | children = ( 197 | 253E17801E34922B00425821 /* Base */, 198 | ); 199 | name = LaunchScreen.storyboard; 200 | sourceTree = ""; 201 | }; 202 | /* End PBXVariantGroup section */ 203 | 204 | /* Begin XCBuildConfiguration section */ 205 | 253E17831E34922B00425821 /* Debug */ = { 206 | isa = XCBuildConfiguration; 207 | buildSettings = { 208 | ALWAYS_SEARCH_USER_PATHS = NO; 209 | CLANG_ANALYZER_NONNULL = YES; 210 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 211 | CLANG_CXX_LIBRARY = "libc++"; 212 | CLANG_ENABLE_MODULES = YES; 213 | CLANG_ENABLE_OBJC_ARC = YES; 214 | CLANG_WARN_BOOL_CONVERSION = YES; 215 | CLANG_WARN_CONSTANT_CONVERSION = YES; 216 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 217 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 218 | CLANG_WARN_EMPTY_BODY = YES; 219 | CLANG_WARN_ENUM_CONVERSION = YES; 220 | CLANG_WARN_INFINITE_RECURSION = YES; 221 | CLANG_WARN_INT_CONVERSION = YES; 222 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 223 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 224 | CLANG_WARN_UNREACHABLE_CODE = YES; 225 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 226 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 227 | COPY_PHASE_STRIP = NO; 228 | DEBUG_INFORMATION_FORMAT = dwarf; 229 | ENABLE_STRICT_OBJC_MSGSEND = YES; 230 | ENABLE_TESTABILITY = YES; 231 | GCC_C_LANGUAGE_STANDARD = gnu99; 232 | GCC_DYNAMIC_NO_PIC = NO; 233 | GCC_NO_COMMON_BLOCKS = YES; 234 | GCC_OPTIMIZATION_LEVEL = 0; 235 | GCC_PREPROCESSOR_DEFINITIONS = ( 236 | "DEBUG=1", 237 | "$(inherited)", 238 | ); 239 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 240 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 241 | GCC_WARN_UNDECLARED_SELECTOR = YES; 242 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 243 | GCC_WARN_UNUSED_FUNCTION = YES; 244 | GCC_WARN_UNUSED_VARIABLE = YES; 245 | IPHONEOS_DEPLOYMENT_TARGET = 10.2; 246 | MTL_ENABLE_DEBUG_INFO = YES; 247 | ONLY_ACTIVE_ARCH = YES; 248 | SDKROOT = iphoneos; 249 | TARGETED_DEVICE_FAMILY = "1,2"; 250 | }; 251 | name = Debug; 252 | }; 253 | 253E17841E34922B00425821 /* Release */ = { 254 | isa = XCBuildConfiguration; 255 | buildSettings = { 256 | ALWAYS_SEARCH_USER_PATHS = NO; 257 | CLANG_ANALYZER_NONNULL = YES; 258 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 259 | CLANG_CXX_LIBRARY = "libc++"; 260 | CLANG_ENABLE_MODULES = YES; 261 | CLANG_ENABLE_OBJC_ARC = YES; 262 | CLANG_WARN_BOOL_CONVERSION = YES; 263 | CLANG_WARN_CONSTANT_CONVERSION = YES; 264 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 265 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 266 | CLANG_WARN_EMPTY_BODY = YES; 267 | CLANG_WARN_ENUM_CONVERSION = YES; 268 | CLANG_WARN_INFINITE_RECURSION = YES; 269 | CLANG_WARN_INT_CONVERSION = YES; 270 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 271 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 272 | CLANG_WARN_UNREACHABLE_CODE = YES; 273 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 274 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 275 | COPY_PHASE_STRIP = NO; 276 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 277 | ENABLE_NS_ASSERTIONS = NO; 278 | ENABLE_STRICT_OBJC_MSGSEND = YES; 279 | GCC_C_LANGUAGE_STANDARD = gnu99; 280 | GCC_NO_COMMON_BLOCKS = YES; 281 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 282 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 283 | GCC_WARN_UNDECLARED_SELECTOR = YES; 284 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 285 | GCC_WARN_UNUSED_FUNCTION = YES; 286 | GCC_WARN_UNUSED_VARIABLE = YES; 287 | IPHONEOS_DEPLOYMENT_TARGET = 10.2; 288 | MTL_ENABLE_DEBUG_INFO = NO; 289 | SDKROOT = iphoneos; 290 | TARGETED_DEVICE_FAMILY = "1,2"; 291 | VALIDATE_PRODUCT = YES; 292 | }; 293 | name = Release; 294 | }; 295 | 253E17861E34922B00425821 /* Debug */ = { 296 | isa = XCBuildConfiguration; 297 | buildSettings = { 298 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 299 | CODE_SIGN_IDENTITY = "iPhone Developer"; 300 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 301 | CODE_SIGN_STYLE = Automatic; 302 | DEVELOPMENT_TEAM = 9W2SHLVZPY; 303 | INFOPLIST_FILE = test/Info.plist; 304 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 305 | PRODUCT_BUNDLE_IDENTIFIER = com.zealfi.testWechar; 306 | PRODUCT_NAME = "$(TARGET_NAME)"; 307 | PROVISIONING_PROFILE = ""; 308 | PROVISIONING_PROFILE_SPECIFIER = ""; 309 | }; 310 | name = Debug; 311 | }; 312 | 253E17871E34922B00425821 /* Release */ = { 313 | isa = XCBuildConfiguration; 314 | buildSettings = { 315 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 316 | CODE_SIGN_IDENTITY = "iPhone Developer"; 317 | DEVELOPMENT_TEAM = ""; 318 | INFOPLIST_FILE = test/Info.plist; 319 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 320 | PRODUCT_BUNDLE_IDENTIFIER = com.test.jsq; 321 | PRODUCT_NAME = "$(TARGET_NAME)"; 322 | }; 323 | name = Release; 324 | }; 325 | /* End XCBuildConfiguration section */ 326 | 327 | /* Begin XCConfigurationList section */ 328 | 253E17691E34922B00425821 /* Build configuration list for PBXProject "test" */ = { 329 | isa = XCConfigurationList; 330 | buildConfigurations = ( 331 | 253E17831E34922B00425821 /* Debug */, 332 | 253E17841E34922B00425821 /* Release */, 333 | ); 334 | defaultConfigurationIsVisible = 0; 335 | defaultConfigurationName = Release; 336 | }; 337 | 253E17851E34922B00425821 /* Build configuration list for PBXNativeTarget "test" */ = { 338 | isa = XCConfigurationList; 339 | buildConfigurations = ( 340 | 253E17861E34922B00425821 /* Debug */, 341 | 253E17871E34922B00425821 /* Release */, 342 | ); 343 | defaultConfigurationIsVisible = 0; 344 | defaultConfigurationName = Release; 345 | }; 346 | /* End XCConfigurationList section */ 347 | }; 348 | rootObject = 253E17661E34922B00425821 /* Project object */; 349 | } 350 | -------------------------------------------------------------------------------- /test.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /test/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // test 4 | // 5 | // Created by 贾仕琪 on 2017/1/22. 6 | // Copyright © 2017年 贾仕琪. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /test/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // test 4 | // 5 | // Created by 贾仕琪 on 2017/1/22. 6 | // Copyright © 2017年 贾仕琪. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | @end 13 | 14 | @implementation AppDelegate 15 | 16 | 17 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 18 | // Override point for customization after application launch. 19 | return YES; 20 | } 21 | 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // 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. 25 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 26 | } 27 | 28 | 29 | - (void)applicationDidEnterBackground:(UIApplication *)application { 30 | 31 | 32 | } 33 | 34 | 35 | - (void)applicationWillEnterForeground:(UIApplication *)application { 36 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 37 | } 38 | 39 | 40 | - (void)applicationDidBecomeActive:(UIApplication *)application { 41 | // 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. 42 | } 43 | 44 | 45 | - (void)applicationWillTerminate:(UIApplication *)application { 46 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 47 | } 48 | 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /test/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 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /test/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 | -------------------------------------------------------------------------------- /test/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 | -------------------------------------------------------------------------------- /test/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 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | NSLocationWhenInUseUsageDescription 24 | 允许定位? 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /test/LocationController.h: -------------------------------------------------------------------------------- 1 | // 2 | // LocationController.h 3 | // test 4 | // 5 | // Created by 贾仕琪 on 2017/1/22. 6 | // Copyright © 2017年 贾仕琪. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | @interface LocationController : UIViewController 12 | /** 13 | * @brief 世界标准地理坐标(WGS-84) 转换成 中国国测局地理坐标(GCJ-02)<火星坐标> 14 | * 15 | * ####只在中国大陆的范围的坐标有效,以外直接返回世界标准坐标 16 | * 17 | * @param location 世界标准地理坐标(WGS-84) 18 | * 19 | * @return 中国国测局地理坐标(GCJ-02)<火星坐标> 20 | */ 21 | + (CLLocationCoordinate2D)wgs84ToGcj02:(CLLocationCoordinate2D)location; 22 | 23 | 24 | /** 25 | * @brief 中国国测局地理坐标(GCJ-02) 转换成 世界标准地理坐标(WGS-84) 26 | * 27 | * ####此接口有1-2米左右的误差,需要精确定位情景慎用 28 | * 29 | * @param location 中国国测局地理坐标(GCJ-02) 30 | * 31 | * @return 世界标准地理坐标(WGS-84) 32 | */ 33 | + (CLLocationCoordinate2D)gcj02ToWgs84:(CLLocationCoordinate2D)location; 34 | 35 | 36 | /** 37 | * @brief 世界标准地理坐标(WGS-84) 转换成 百度地理坐标(BD-09) 38 | * 39 | * @param location 世界标准地理坐标(WGS-84) 40 | * 41 | * @return 百度地理坐标(BD-09) 42 | */ 43 | + (CLLocationCoordinate2D)wgs84ToBd09:(CLLocationCoordinate2D)location; 44 | 45 | 46 | /** 47 | * @brief 中国国测局地理坐标(GCJ-02)<火星坐标> 转换成 百度地理坐标(BD-09) 48 | * 49 | * @param location 中国国测局地理坐标(GCJ-02)<火星坐标> 50 | * 51 | * @return 百度地理坐标(BD-09) 52 | */ 53 | + (CLLocationCoordinate2D)gcj02ToBd09:(CLLocationCoordinate2D)location; 54 | 55 | 56 | /** 57 | * @brief 百度地理坐标(BD-09) 转换成 中国国测局地理坐标(GCJ-02)<火星坐标> 58 | * 59 | * @param location 百度地理坐标(BD-09) 60 | * 61 | * @return 中国国测局地理坐标(GCJ-02)<火星坐标> 62 | */ 63 | + (CLLocationCoordinate2D)bd09ToGcj02:(CLLocationCoordinate2D)location; 64 | 65 | 66 | /** 67 | * @brief 百度地理坐标(BD-09) 转换成 世界标准地理坐标(WGS-84) 68 | * 69 | * ####此接口有1-2米左右的误差,需要精确定位情景慎用 70 | * 71 | * @param location 百度地理坐标(BD-09) 72 | * 73 | * @return 世界标准地理坐标(WGS-84) 74 | */ 75 | + (CLLocationCoordinate2D)bd09ToWgs84:(CLLocationCoordinate2D)location; 76 | @end 77 | -------------------------------------------------------------------------------- /test/LocationController.m: -------------------------------------------------------------------------------- 1 | // 2 | // LocationController.m 3 | // test 4 | // 5 | // Created by 贾仕琪 on 2017/1/22. 6 | // Copyright © 2017年 贾仕琪. All rights reserved. 7 | // 8 | 9 | #import "LocationController.h" 10 | #import 11 | #define LAT_OFFSET_0(x,y) -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * sqrt(fabs(x)) 12 | #define LAT_OFFSET_1 (20.0 * sin(6.0 * x * M_PI) + 20.0 * sin(2.0 * x * M_PI)) * 2.0 / 3.0 13 | #define LAT_OFFSET_2 (20.0 * sin(y * M_PI) + 40.0 * sin(y / 3.0 * M_PI)) * 2.0 / 3.0 14 | #define LAT_OFFSET_3 (160.0 * sin(y / 12.0 * M_PI) + 320 * sin(y * M_PI / 30.0)) * 2.0 / 3.0 15 | 16 | #define LON_OFFSET_0(x,y) 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * sqrt(fabs(x)) 17 | #define LON_OFFSET_1 (20.0 * sin(6.0 * x * M_PI) + 20.0 * sin(2.0 * x * M_PI)) * 2.0 / 3.0 18 | #define LON_OFFSET_2 (20.0 * sin(x * M_PI) + 40.0 * sin(x / 3.0 * M_PI)) * 2.0 / 3.0 19 | #define LON_OFFSET_3 (150.0 * sin(x / 12.0 * M_PI) + 300.0 * sin(x / 30.0 * M_PI)) * 2.0 / 3.0 20 | 21 | #define RANGE_LON_MAX 137.8347 22 | #define RANGE_LON_MIN 72.004 23 | #define RANGE_LAT_MAX 55.8271 24 | #define RANGE_LAT_MIN 0.8293 25 | // jzA = 6378245.0, 1/f = 298.3 26 | // b = a * (1 - f) 27 | // ee = (a^2 - b^2) / a^2; 28 | #define jzA 6378245.0 29 | #define jzEE 0.00669342162296594323 30 | 31 | 32 | 33 | @implementation LocationController 34 | 35 | + (double)transformLat:(double)x bdLon:(double)y 36 | { 37 | double ret = LAT_OFFSET_0(x, y); 38 | ret += LAT_OFFSET_1; 39 | ret += LAT_OFFSET_2; 40 | ret += LAT_OFFSET_3; 41 | return ret; 42 | } 43 | 44 | + (double)transformLon:(double)x bdLon:(double)y 45 | { 46 | double ret = LON_OFFSET_0(x, y); 47 | ret += LON_OFFSET_1; 48 | ret += LON_OFFSET_2; 49 | ret += LON_OFFSET_3; 50 | return ret; 51 | } 52 | 53 | + (BOOL)outOfChina:(double)lat bdLon:(double)lon 54 | { 55 | if (lon < RANGE_LON_MIN || lon > RANGE_LON_MAX) 56 | return true; 57 | if (lat < RANGE_LAT_MIN || lat > RANGE_LAT_MAX) 58 | return true; 59 | return false; 60 | } 61 | 62 | + (CLLocationCoordinate2D)gcj02Encrypt:(double)ggLat bdLon:(double)ggLon 63 | { 64 | CLLocationCoordinate2D resPoint; 65 | double mgLat; 66 | double mgLon; 67 | if ([self outOfChina:ggLat bdLon:ggLon]) { 68 | resPoint.latitude = ggLat; 69 | resPoint.longitude = ggLon; 70 | return resPoint; 71 | } 72 | double dLat = [self transformLat:(ggLon - 105.0)bdLon:(ggLat - 35.0)]; 73 | double dLon = [self transformLon:(ggLon - 105.0) bdLon:(ggLat - 35.0)]; 74 | double radLat = ggLat / 180.0 * M_PI; 75 | double magic = sin(radLat); 76 | magic = 1 - jzEE * magic * magic; 77 | double sqrtMagic = sqrt(magic); 78 | dLat = (dLat * 180.0) / ((jzA * (1 - jzEE)) / (magic * sqrtMagic) * M_PI); 79 | dLon = (dLon * 180.0) / (jzA / sqrtMagic * cos(radLat) * M_PI); 80 | mgLat = ggLat + dLat; 81 | mgLon = ggLon + dLon; 82 | 83 | resPoint.latitude = mgLat; 84 | resPoint.longitude = mgLon; 85 | return resPoint; 86 | } 87 | 88 | + (CLLocationCoordinate2D)gcj02Decrypt:(double)gjLat gjLon:(double)gjLon { 89 | CLLocationCoordinate2D gPt = [self gcj02Encrypt:gjLat bdLon:gjLon]; 90 | double dLon = gPt.longitude - gjLon; 91 | double dLat = gPt.latitude - gjLat; 92 | CLLocationCoordinate2D pt; 93 | pt.latitude = gjLat - dLat; 94 | pt.longitude = gjLon - dLon; 95 | return pt; 96 | } 97 | 98 | + (CLLocationCoordinate2D)bd09Decrypt:(double)bdLat bdLon:(double)bdLon 99 | { 100 | CLLocationCoordinate2D gcjPt; 101 | double x = bdLon - 0.0065, y = bdLat - 0.006; 102 | double z = sqrt(x * x + y * y) - 0.00002 * sin(y * M_PI); 103 | double theta = atan2(y, x) - 0.000003 * cos(x * M_PI); 104 | gcjPt.longitude = z * cos(theta); 105 | gcjPt.latitude = z * sin(theta); 106 | return gcjPt; 107 | } 108 | 109 | +(CLLocationCoordinate2D)bd09Encrypt:(double)ggLat bdLon:(double)ggLon 110 | { 111 | CLLocationCoordinate2D bdPt; 112 | double x = ggLon, y = ggLat; 113 | double z = sqrt(x * x + y * y) + 0.00002 * sin(y * M_PI); 114 | double theta = atan2(y, x) + 0.000003 * cos(x * M_PI); 115 | bdPt.longitude = z * cos(theta) + 0.0065; 116 | bdPt.latitude = z * sin(theta) + 0.006; 117 | return bdPt; 118 | } 119 | 120 | 121 | + (CLLocationCoordinate2D)wgs84ToGcj02:(CLLocationCoordinate2D)location 122 | { 123 | return [self gcj02Encrypt:location.latitude bdLon:location.longitude]; 124 | } 125 | 126 | + (CLLocationCoordinate2D)gcj02ToWgs84:(CLLocationCoordinate2D)location 127 | { 128 | return [self gcj02Decrypt:location.latitude gjLon:location.longitude]; 129 | } 130 | 131 | 132 | + (CLLocationCoordinate2D)wgs84ToBd09:(CLLocationCoordinate2D)location 133 | { 134 | CLLocationCoordinate2D gcj02Pt = [self gcj02Encrypt:location.latitude 135 | bdLon:location.longitude]; 136 | return [self bd09Encrypt:gcj02Pt.latitude bdLon:gcj02Pt.longitude] ; 137 | } 138 | 139 | + (CLLocationCoordinate2D)gcj02ToBd09:(CLLocationCoordinate2D)location 140 | { 141 | return [self bd09Encrypt:location.latitude bdLon:location.longitude]; 142 | } 143 | 144 | + (CLLocationCoordinate2D)bd09ToGcj02:(CLLocationCoordinate2D)location 145 | { 146 | return [self bd09Decrypt:location.latitude bdLon:location.longitude]; 147 | } 148 | 149 | + (CLLocationCoordinate2D)bd09ToWgs84:(CLLocationCoordinate2D)location 150 | { 151 | CLLocationCoordinate2D gcj02 = [self bd09ToGcj02:location]; 152 | return [self gcj02Decrypt:gcj02.latitude gjLon:gcj02.longitude]; 153 | } 154 | 155 | @end 156 | 157 | -------------------------------------------------------------------------------- /test/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // test 4 | // 5 | // Created by 贾仕琪 on 2017/1/22. 6 | // Copyright © 2017年 贾仕琪. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /test/ViewController.m: -------------------------------------------------------------------------------- 1 | 2 | // 3 | // ViewController.m 4 | // test 5 | // 6 | // Created by 贾仕琪 on 2017/1/22. 7 | // Copyright © 2017年 贾仕琪. All rights reserved. 8 | // 9 | 10 | #import "ViewController.h" 11 | #import "LocationController.h" 12 | #import 13 | @interface ViewController () 14 | @property (nonatomic, strong)CLLocationManager *locationManager; 15 | @end 16 | 17 | @implementation ViewController 18 | 19 | - (void)viewDidLoad { 20 | [super viewDidLoad]; 21 | //第一步从高德地图上获取坐标 22 | 23 | //http://lbs.amap.com/console/show/picker 24 | //第二步转换成Wgs坐标系统 25 | CLLocation *loca = [[CLLocation alloc]initWithLatitude:31.215257 longitude:121.53381]; 26 | CLLocationCoordinate2D c2d = [LocationController gcj02ToWgs84:loca.coordinate]; 27 | NSLog(@"转换后: %f %f",c2d.latitude,c2d.longitude); 28 | 29 | //第三步在.gpx中添加地图转换后的坐标 30 | 31 | //运行 32 | 33 | // _locationManager =[[CLLocationManager alloc]init]; 34 | // _locationManager.delegate =self; 35 | // //设置定位经准 36 | // _locationManager.desiredAccuracy =kCLLocationAccuracyNearestTenMeters; 37 | // [_locationManager requestWhenInUseAuthorization];//否则,ios10不弹定位框 38 | // _locationManager.distanceFilter =10.0f; 39 | // //开始定位 40 | // [_locationManager startUpdatingLocation]; 41 | UILabel * lable = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 300, 100)]; 42 | lable.numberOfLines = 2; 43 | lable.text = @"模拟定位已启动,不要断开连接,不要关闭程序,按home键返回桌面"; 44 | lable.center = self.view.center; 45 | lable.textColor = [UIColor redColor]; 46 | [self.view addSubview:lable]; 47 | } 48 | //-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations{ 49 | // 50 | // CLLocation *newLocation =locations[0]; 51 | // 52 | // CLLocationCoordinate2D oCoordinate =newLocation.coordinate; 53 | // 54 | // [_locationManager stopUpdatingLocation]; 55 | // 56 | // 57 | // 58 | // NSLog(@"经度------%f\n------纬度%f",oCoordinate.longitude,oCoordinate.latitude); 59 | // 60 | // //创建地理位置解码编码器对象 61 | // 62 | // CLGeocoder *geoCoder =[[CLGeocoder alloc]init]; 63 | // 64 | // [geoCoder reverseGeocodeLocation:newLocation completionHandler:^(NSArray * _Nullable placemarks, NSError * _Nullable error) { 65 | // 66 | // for (CLPlacemark *place in placemarks) { 67 | // 68 | // NSLog(@"城市-----%@",place.locality); 69 | // 70 | // } 71 | // 72 | // }]; 73 | // 74 | //} 75 | // 76 | //- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error{ 77 | // 78 | // if ([error code] == kCLErrorDenied){ 79 | // 80 | // //访问被拒绝 81 | // 82 | // NSLog(@"访问被拒绝"); 83 | // 84 | // } 85 | // 86 | // if ([error code] == kCLErrorLocationUnknown) { 87 | // 88 | // //无法获取位置信息 89 | // 90 | // NSLog(@"无法获取位置信息"); 91 | // 92 | // } 93 | // 94 | //} 95 | // 96 | //- (void)didReceiveMemoryWarning { 97 | // [super didReceiveMemoryWarning]; 98 | // // Dispose of any resources that can be recreated. 99 | //} 100 | 101 | 102 | @end 103 | -------------------------------------------------------------------------------- /test/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // test 4 | // 5 | // Created by 贾仕琪 on 2017/1/22. 6 | // Copyright © 2017年 贾仕琪. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | --------------------------------------------------------------------------------