{"id":13841909,"url":"https://github.com/jiangboLee/ChangeLocation","last_synced_at":"2025-07-11T13:33:04.345Z","repository":{"id":218715135,"uuid":"119018518","full_name":"jiangboLee/ChangeLocation","owner":"jiangboLee","description":"改变自己的定位地址(免越狱打卡)","archived":false,"fork":false,"pushed_at":"2019-02-12T10:19:09.000Z","size":21,"stargazers_count":193,"open_issues_count":4,"forks_count":60,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-08-05T17:29:43.835Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jiangboLee.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLocation/ChangeLocation.xcodeproj/project.pbxproj","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2018-01-26T07:11:32.000Z","updated_at":"2024-08-02T19:01:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"683ef6e5-12b3-4d9f-9a8b-e8de20405d9e","html_url":"https://github.com/jiangboLee/ChangeLocation","commit_stats":null,"previous_names":["jiangbolee/changelocation"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiangboLee%2FChangeLocation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiangboLee%2FChangeLocation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiangboLee%2FChangeLocation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiangboLee%2FChangeLocation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jiangboLee","download_url":"https://codeload.github.com/jiangboLee/ChangeLocation/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225729754,"owners_count":17515159,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T17:01:23.921Z","updated_at":"2024-11-21T12:30:38.122Z","avatar_url":"https://github.com/jiangboLee.png","language":"Objective-C","funding_links":[],"categories":["Objective-C","Objective-C (33)"],"sub_categories":[],"readme":"# ChangeLocation\n改变自己的定位地址，已实际验证！！！在家微信打卡，老婆钉钉打卡都没问题。哈哈。。。。\n\n![迟到.jpeg](http://upload-images.jianshu.io/upload_images/2868618-af39967557889e2e.jpeg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)\n\n大冬天的起床多不容易。现在公司都是钉钉打卡，微信打卡。老婆一直要我搞一个可以随时打卡的钉钉，我说那要越狱啊，现在咱手机都是11.0以上系统，没有完美越狱啊！！！然后今天发给我一个链接[iOS 模拟定位，让你在家钉钉打卡！](https://www.jianshu.com/p/38782cb3f688),然后照着大神自己写了下demo，回家装吧~\n## 地图坐标系\n在地图开发中：我们会接触到3中类型的地图坐标系：\n1. WGS－84原始坐标系，一般用国际GPS纪录仪记录下来的经纬度，通过GPS定位拿到的原始经纬度，Google和高德地图定位的的经纬度（国外）都是基于WGS－84坐标系的；但是在国内是不允许直接用WGS84坐标系标注的，必须经过加密后才能使用；\n2. GCJ－02坐标系，又名“火星坐标系”，是我国国测局独创的坐标体系，由WGS－84加密而成，在国内，必须至少使用GCJ－02坐标系，或者使用在GCJ－02加密后再进行加密的坐标系，如百度坐标系。高德和Google在国内都是使用GCJ－02坐标系，可以说，GCJ－02是国内最广泛使用的坐标系；\n3. 百度坐标系:bd-09，百度坐标系是在GCJ－02坐标系的基础上再次加密偏移后形成的坐标系，只适用于百度地图。(目前百度API提供了从其它坐标系转换为百度坐标系的API，但却没有从百度坐标系转为其他坐标系的API)\n\n而我们iOS端采用的定位坐标系是WGS-84.\n- 我们可以直接通过定位代码拿到当前位置的经纬度。\n```objective-c\n - (void)viewDidAppear:(BOOL)animated {\n    [super viewDidAppear:animated];\n    \n    _manager = [[CLLocationManager alloc] init];\n    _manager.delegate = self;\n//    [manager requestAlwaysAuthorization];\n    [_manager requestWhenInUseAuthorization];\n    _manager.desiredAccuracy = kCLLocationAccuracyBest;\n    _manager.distanceFilter = 1.0;\n    [_manager startUpdatingLocation];\n}\n\n- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray\u003cCLLocation *\u003e *)locations {\n    \n    CLLocation *currentLocation = [locations lastObject];\n    //1.如果打卡地点是这里，当前的经纬度。\n    //2.直接copy下面的经纬度，无需转换\n    //3.去Location1.gpx修改经纬度\n    //当前的经纬度\n    NSLog(@\"当前的经纬度 %f,%f\",currentLocation.coordinate.latitude,currentLocation.coordinate.longitude);\n    self.location2DLable.text = [NSString stringWithFormat:@\"纬度:%f,经度:%f\",currentLocation.coordinate.latitude,currentLocation.coordinate.longitude];\n    \n    //地理反编码 可以根据坐标(经纬度)确定位置信息(街道 门牌等)\n    CLGeocoder *geoCoder = [[CLGeocoder alloc]init];\n    [geoCoder reverseGeocodeLocation:currentLocation completionHandler:^(NSArray\u003cCLPlacemark *\u003e * _Nullable placemarks, NSError * _Nullable error) {\n        if (placemarks.count \u003e0) {\n            CLPlacemark *placeMark = placemarks[0];\n            NSString *currentCity = placeMark.locality;\n            if (!currentCity) {\n                currentCity = @\"无法定位当前城市\";\n            }\n            //看需求定义一个全局变量来接收赋值\n            NSLog(@\"当前国家 - %@\",placeMark.country);//当前国家\n            NSLog(@\"当前城市 - %@\",currentCity);//当前城市\n            NSLog(@\"当前位置 - %@\",placeMark.subLocality);//当前位置\n            NSLog(@\"当前街道 - %@\",placeMark.thoroughfare);//当前街道\n            NSLog(@\"具体地址 - %@\",placeMark.name);//具体地址\n            self.locationLable.text = [NSString stringWithFormat:@\"%@,%@,%@,%@,%@\",placeMark.country,currentCity,placeMark.subLocality,placeMark.thoroughfare,placeMark.name];\n        }\n    }];\n}\n```\n- 我们要拿到其他位置的坐标点，需要定位到其他位置。\n这个时候我们可以先通过[高德地图](http://lbs.amap.com/console/show/picker)得到高德的坐标系，然后通过代码转换成WGS 坐标系。\n```objective-c\n//如果要想知道任意位置的坐标\n    //1.去高德地图http://lbs.amap.com/console/show/picker，选中自己坐标\n    //楼主在上海哦~\n    //杭州  120.211963,30.274602 \n    //2.在进行坐标转换\n    CLLocationCoordinate2D location2D = CLLocationCoordinate2DMake(30.274602, 120.211963);\n    CLLocationCoordinate2D WGSlocation2D = [ChangeLoction gcj02ToWgs84:location2D];\n    NSLog(@\"纬度：%f,经度：%f\",WGSlocation2D.latitude , WGSlocation2D.longitude);\n    //纬度：30.277029,经度：120.207428\n    //3.去Location1.gpx修改经纬度\n```\n其中一大堆坐标系转来转去的方法在项目代码中，有兴趣可以下载看看\n## 新建项目\n现在我们已经能获得到定位的坐标系了。现在开始调试。可以新建一个项目，新建一个gpx文件。gpx是一种用于存储坐标数据的 XML 文件格式。它可以储存在一条路上的路点，轨迹，路线，且易于处理和转换到其他格式。OpenStreetMap 使用的所有 GPS 数据要转换为 GPX 格式才能上传。\n![gpx.png](http://upload-images.jianshu.io/upload_images/2868618-b4069da23ccbb720.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)\n然后将自己要定位的经纬度写入文件中。\n![修改经纬度.png](http://upload-images.jianshu.io/upload_images/2868618-5235f249332aea00.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)\n好的。项目完成了！就这么简单\n## 开始调试\n##### 必须连接上真机。然后运行。![Snip20180126_44.png](http://upload-images.jianshu.io/upload_images/2868618-6dc6e6576ac8e424.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)\n运行后，点击Debug---\u003eSimulate Location --\u003e Location1（这个是你创建gpx的文件名哦）\n这时你会发现手机当前的定位已经切换到你的经纬度。\n**这个时候，你打开手机的其他软件，包括自带的地图，微信，钉钉。。。你会发现所有的当前定位都是你设置的位置了。然后，你想怎么弄就怎么弄咯**\n你要修改另一个位置，只需要重新修改gpx中的参数，然后重新运行，发现还是上次的位置。这个时候只需要再点Location1，就可以更新到最新位置。\n## 结束语\n现在我的定位是自定义的。如果要恢复原来的怎么办？第一感觉，我选了Don't Simulate Location,发现当时没反应（原来只需要重新运行一遍就好（iphone6 10.3版本）），但后面发现来回操作多次，原生地图的定位一直在刷新（干脆也重启手机吧）。你以为结束了吗？发现iPhone X（11.2）竟然按上面操作没反应，改不回来了，应用杀掉也不行（没办法，只好重新手机OK了）。\n\n#### iOS程序猿又有人要啦~ 赶快找你们的iOS程序猿给你们装一个公司的定位吧~哈哈。。。。妈妈再也不怕我上班迟到了！\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FjiangboLee%2FChangeLocation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FjiangboLee%2FChangeLocation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FjiangboLee%2FChangeLocation/lists"}