core-location

Detecting if a user is moving in a car

别来无恙 提交于 2019-12-17 15:22:49
问题 NOTICE : This question was originally posted before Apple introduced motion-detection hardware and associated APIs in the iOS SDK. Answers to this question, however, remain relevant. I'm creating an iPhone iOS app which involves tracking a user's running and / or walking. It is very important that the recorded results of the users runs and walks remain honest. I need a way to catch a user who may be cheating (or accidentally have left the tracker on) when using a car. To check if the user is

Get device location (only country) in iOS

你。 提交于 2019-12-17 08:12:21
问题 I need to get the country location of a iOS device. I've been trying to use CoreLocation with MKReverseGeocoder. However this seems to return erraneous quite frequently. And I only need the country, no need for streets and such. How can this be done in a more stable way? 回答1: NSLocale is just a setting about currently used regional settings, it doesn't mean the actual country you're in. Use CLLocationManager to get current location & CLGeocoder to perform reverse-geocoding. You can get

Returning object from callback in Swift

拟墨画扇 提交于 2019-12-17 07:57:08
问题 I want to wrap the geocoder.geocdeAddressString in another method with other logic. public func placemarkForSearchResult<T>(searchResult: T) -> CLPlacemark? { if let searchResult = searchResult as? String { let geocoder = CLGeocoder() geocoder.geocodeAddressString(searchResult, completionHandler: { (placemarks, error) -> Void in // Check for returned placemarks if let placemarks = placemarks where placemarks.count > 0 { return placemarks[0] as! CLPlacemark // CLPlacemark is not convertible to

Returning object from callback in Swift

自古美人都是妖i 提交于 2019-12-17 07:56:20
问题 I want to wrap the geocoder.geocdeAddressString in another method with other logic. public func placemarkForSearchResult<T>(searchResult: T) -> CLPlacemark? { if let searchResult = searchResult as? String { let geocoder = CLGeocoder() geocoder.geocodeAddressString(searchResult, completionHandler: { (placemarks, error) -> Void in // Check for returned placemarks if let placemarks = placemarks where placemarks.count > 0 { return placemarks[0] as! CLPlacemark // CLPlacemark is not convertible to

iOS HTTP request while in background

做~自己de王妃 提交于 2019-12-17 07:28:50
问题 It is possible to make HTTP async requests to PHP server while the app being in background? The app is a location based one, and should gather current location and send the coordinates to server every 5(or other value) minutes. Can I make the http posts to the server even the app is in background? I read lot of thoughts about this, but some of them told that can be done, others that can't be done. Thanks, Alex. 回答1: It can be done but it is unreliable because you ask the OS for time to send

Moving a CLLocation by x meters

☆樱花仙子☆ 提交于 2019-12-17 07:24:11
问题 I have a CLLocation defined, and I'd like to move that point x meters to the east and y meters to the south. How may I achieve that? 回答1: There is a C function that is close to what you are asking but it takes a bearing and distance. It's in my UtilitiesGeo class on github. You would pass the latitude and longitude from your CLLocation to it and then create a new CLLocation from the resulting lat2 and lon2 that it returns: /*--------------------------------------------------------------------

Centering MKMapView on spot N-pixels below pin

三世轮回 提交于 2019-12-17 07:17:21
问题 Want to center MKMapView on a point N-pixels below a given pin ( which may or may not be visible in the current MapRect ). I've been trying to solve this using various plays with -(CLLocationCoordinate2D)convertPoint:(CGPoint)point toCoordinateFromView:(UIView *)view to no success. Anyone been down this road ( no pun intended )? 回答1: The easiest technique is to just shift the map down, say 40% from where the coordinate would be, taking advantage of the span of the region of the MKMapView . If

distanceFromLocation - Calculate distance between two points

痞子三分冷 提交于 2019-12-17 07:09:50
问题 Just a quick question on Core Location, I'm trying to calculate the distance between two points, code is below: -(void)locationChange:(CLLocation *)newLocation:(CLLocation *)oldLocation { // Configure the new event with information from the location. CLLocationCoordinate2D newCoordinate = [newLocation coordinate]; CLLocationCoordinate2D oldCoordinate = [oldLocation coordinate]; CLLocationDistance kilometers = [newCoordinate distanceFromLocation:oldCoordinate] / 1000; // Error ocurring here.

iOS: App is not asking user's permission while installing the app. getting kCLAuthorizationStatusNotDetermined every time - Objective-c & Swift

╄→尐↘猪︶ㄣ 提交于 2019-12-17 06:25:34
问题 I am trying to fetch user location in my iOS app. I have included corelocation framework in my project first. Then on a button click I am invoking the core location api as below. When I am trying to install this in a device, the core location never asks the user permission. When I try to fetch the location on button click, I am getting kCLAuthorizationStatusNotDetermined as the authorisationStatus. Please help me in this. I have no clue what is happening. - (IBAction)fetchLessAccurateLocation

SceneKit view is rendered backwards

我们两清 提交于 2019-12-14 04:13:58
问题 I'm attempting my first SceneKit app. My goal is to simulate a view from the surface of the Earth and being able to point the device's camera in any direction and overlay information over the camera view. To start, I'm simply trying to get the SceneKit camera view to match the device's orientation. To verify that it is working as desired, I am adding a bunch of spheres at specific latitude and longitude coordinates. Everything is working except for one important issue. The view is mirrored