cllocation

Get the GPS coordinate given the current location, bearing and distance

微笑、不失礼 提交于 2019-12-13 05:55:24
问题 I'm trying to get a GPS coordinate given the current location, bearing and distance. But I can't find any related to cocoa-touch. I've found the formula here Get lat/long given current point, distance and bearing Is there an easier method for iOS? Thanks in advance. 回答1: Converted the code in the link to Objective-C. - (double)degreesToRadians:(double)degrees { return degrees * M_PI / 180; } - (double)radiansToDegrees:(double)radians { return radians * 180/ M_PI; } - (CLLocationCoordinate2D

EDSunriseSet returning 0

别等时光非礼了梦想. 提交于 2019-12-13 02:22:59
问题 I am using the EDSunriseSet class from https://github.com/erndev/EDSunriseSet I have the code: if(longitude == 0 && latitude == 0){ longitude = 51.50722; latitude = -0.12750; } EDSunriseSet *sunrise = [EDSunriseSet sunrisesetWithTimezone:[NSTimeZone localTimeZone] latitude:latitude longitude:longitude]; NSLog(@"With lat = %f and long = %F; sunrise is at: %@",latitude,longitude,sunrise.localSunset); and it returns: <NSDateComponents: 0x10a2743a0> Hour: 0 Minute: 0 Second: 0 Is the issue on my

CLLocation background services enablement changes between ios 6 and ios 9

我只是一个虾纸丫 提交于 2019-12-13 02:15:35
问题 I have a Live App released on ios 7 and using background services. I am recompiling the app under ios 9 and have now found that the app does not receive any location update while it enters the background. I have made the following change: I've added the following key to my info.plist file with an accompanying String value: NSLocationWhenInUseUsageDescription Still when the app goes in background, it stops receiving location updates. Is there any other setting or method I should include which

CLGeocoder returns null results for city and state when using current location data

南楼画角 提交于 2019-12-13 01:18:14
问题 Hi I am trying to get the name of city and state using CLGeocoder. However, placemark.addressDictionary is returning me : { FormattedAddressLines = ( "South Atlantic Ocean" ); Name = "South Atlantic Ocean"; Ocean = "South Atlantic Ocean"; } and placemark is: South Atlantic Ocean, South Atlantic Ocean @ <-42.60533670,-21.93128480> +/- 100.00m, region CLCircularRegion (identifier:'<-41.51023865,-31.60774370> radius 4958095.65', center:<-41.51023865,-31.60774370>, radius:4958095.65m) Also, NSLog

ALAssetPropertyLocation not working on any iOS 4.0+ on 3gs iPhones but working perfectly on iPhone4

匆匆过客 提交于 2019-12-12 10:29:23
问题 I've got an app with location services ENABLED (from settings etc), and I'm reading all the photos from my device using ALAssetsLibrary. It works perfectly on iPhone4 iOS 4.2.1, but the same code and the same assets DONT WORK on any 3gs any iOS (from 4.0 to 4.2.1). The problem is that it retrieves always an invalid CLLocation on the 3gs. Even on the same picture (copied across both devices) on the iPhone4 returns a valid CLLocation, on the 3gs it returns invalid! The picture image itself it's

converting a CLLocationCoordinate2D type to number or string

风格不统一 提交于 2019-12-12 08:13:35
问题 I was wondering how to convert latitude and longitude values of CLLocationCoordinate2D to numbers or string values. Iver tried a few different ways but they arene't working: CLLocationCoordinate2D centerCoord; centerCoord.latitude = self.locModel.userLocation.coordinate.latitude ; centerCoord.longitude = self.locModel.userLocation.coordinate.longitude; NSString *tmpLat = [[NSString alloc] initWithFormat:@"%g", centerCoord.latitude]; NSString *tmpLong = [[NSString alloc] initWithFormat:@"%g",

recieving location updates after app is terminated

▼魔方 西西 提交于 2019-12-12 07:13:50
问题 I need to keep track of the user location all the time (but not drain the battery). I understand the only way to get updates after app is terminated is using startMonitoringSignificantLocationChanges. From Apple's Location Awareness Programming Guide on startMonitoringSignificantLocationChanges: If you start this service and your application is subsequently terminated, the system automatically relaunches the application into the background if a new event arrives. In such a case, the options

swift 3 Calculate distance to current location and sort result from closet to furthest

末鹿安然 提交于 2019-12-12 04:34:51
问题 I'm trying to to calculate the distance from an event to my current location, sort the results and populate that in a tableview. I keep getting error for optional unwrapped value distance is nil. private func observeEvents() { refHandle = ref.observe(.childAdded, with: { (snapshot) -> Void in let eventDetails = snapshot.value as! Dictionary<String, AnyObject> let eventID = snapshot.key let location = eventDetails["location"] as! String! //calculating distance self.forwardGeocoding(address:

Saving location coordinates to Core data- Swift 3

老子叫甜甜 提交于 2019-12-12 03:54:00
问题 I want to save location coordinates into Core Data- what is the right way of storing these and retrieving them? At the moment I am doing this and getting errors: var newPlaceCoordinate = CLLocationCoordinate2D() var newPlaceLatitude = CLLocationDegrees() var newPlaceLongitude = CLLocationDegrees() I get my coordinates from using Google maps API using the autocomplete widget. let newPlaceCoordinate = place.coordinate self.newPlaceCoordinate = place.coordinate let newPlaceLatitude = place

CLLocation speed return -1.0

社会主义新天地 提交于 2019-12-12 03:52:20
问题 I have problem. My GPS (on iPad mini 2 in Wifi and on iPhone 6 in 3G/4G) the speed return -1.0. Have an idea? This what i receive in console log: Long: 12.5245, Lat: 41.9456, Speed:-1.0, kph: -3.6 Here the code in didUpdateLocations() let userLocation: CLLocation = locations[0] var speed: CLLocationSpeed = CLLocationSpeed() speed = (locationManager.location?.speed)! SpeedLabel.text = String(format: "%.0f km/h", speed * 3.6) let long = String(Float(userLocation.coordinate.longitude)) let lat =