cllocation

Reverse function of MKCoordinateRegionMakeWithDistance?

走远了吗. 提交于 2019-12-05 18:34:21
MapKit's built in function MKCoordinateRegionMakeWithDistance takes distances in meters and turns them into a MKCoordinateRegion : func MKCoordinateRegionMakeWithDistance( _ centerCoordinate: CLLocationCoordinate2D, _ latitudinalMeters: CLLocationDistance, _ longitudinalMeters: CLLocationDistance) -> MKCoordinateRegion is there a reverse function that takes a MKCoordinateRegion and gives me latitudinalMeters and longitudinalMeters? MKCoordinateRegion gives a center (latitude and longitude) and span (delta latitude and longitude). Given these values, you can determine the location of the edges

calculating 'timeIntervalSinceNow' with a negative value (CLLocation example)?

做~自己de王妃 提交于 2019-12-05 17:41:46
i don't understand this example from the doc : the timeIntervalSinceNow method should show a positive value, but how can we reach "5" as mentioned in the code? (i think it's either 0 more or less, or -10 , -20, -30 etc... but how can we get a positive value such as 5?) : - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { // test the age of the location measurement to determine if the measurement is cached // in most cases you will not want to rely on cached measurements NSTimeInterval locationAge = -

Convert String to CLLocationCoordinate2D in swift

余生颓废 提交于 2019-12-05 17:22:17
问题 using Firebase as my backend, I've got a series of strings that are latitude and longitude coordinates, how can I convert them to CLLocationCoordinate2D so that I can use them for annotations? Here is the code that gets the info from Firebase every time its updated var UpdateRef = Firebase(url:"https://ici.firebaseio.com/users") UpdateRef.observeEventType(.ChildChanged, withBlock: { (snapshot) in let MomentaryLatitude = snapshot.value["latitude"] as? String let MomentaryLongitude = snapshot

Can I get the accuracy of GPS location in iOS?

左心房为你撑大大i 提交于 2019-12-05 10:17:07
I've seen Android developers get the accuracy of a GPS location. Is there a way that I can get the accuracy of my currenct GPS location in iOS? I am using the code from this answer to get my location: locationManager = [[CLLocationManager alloc] init]; locationManager.delegate = self; locationManager.distanceFilter = kCLDistanceFilterNone; locationManager.desiredAccuracy = kCLLocationAccuracyBest; [locationManager startUpdatingLocation]; - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { NSLog(@

Convert GPS coordinates to a city name / address in Swift

守給你的承諾、 提交于 2019-12-05 07:18:38
I have a latitude/longitude location that I want to convert to the location name String in Swift. What is the best way to do this? i believe it's best to use the reverseGeocodeLocation function but not exactly sure how to. This is what I have so far: func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!) { if (locationFixAchieved == false) { locationFixAchieved = true var locationArray = locations as NSArray var locationObj = locationArray.lastObject as CLLocation var coord = locationObj.coordinate var latitude = coord.latitude var longitude = coord

how can I send coordinates to parse and save it as parse PFGeopoint

烈酒焚心 提交于 2019-12-05 06:44:17
问题 How can i send coordinates to Parse fetched by CLLocation and save it there as PFGeoPoint's latitude and longitude? I am able to get the coordinates from CLLocation and I want to send it to Parse. In Parse I have a column named "coordinates" of type PFGeoPoint which has two fields.Now I want to save the coordinates which I have got from CLLocation to Parse Column coordinates. can anyone please help me with this? I am new to iOS and Parse. 回答1: Two steps: Convert CLLocation to PFGeoPoint /

How to remove cache of cllocation?

爱⌒轻易说出口 提交于 2019-12-05 03:09:12
问题 I am developing an iPhone app which is a location aware app . Currentlly the app is working fine except the caching of previous location . The first time I start the application location manager fetches the current location and then I display nearby things based on the current location . But from the next it uses previously fetched location and until I restart the phone it will fetch the same location . So up to this point I am clear that the location manager caches the location . So my

CLLocation distanceFromLocation (in Swift?)

别来无恙 提交于 2019-12-04 23:19:43
问题 Can somebody please help me convert the following Objective-C statement to Swift? CLLocationDistance distance = [fromLocation distanceFromLocation:toLocation]; I know that it must be simple to do that. I am brand new to iOS programming and any help will be greatly appreciated. Thank you! :-) 回答1: let distance = fromLocation.distanceFromLocation(toLocation) New syntax: let distance = aLocation.distance(from: anotherLocation) 回答2: func distanceFromLocation(_ location: CLLocation!) ->

calculate distance between 2 coordinates iphone - best practice

我是研究僧i 提交于 2019-12-04 20:51:25
I'm finishing an App in wish i need to show the user the distance between him and about 500 coordinates. using the CLLocation method to calculate it, works well, but it takes about 1 minute in iPhone 4 to finish calculations for each location. What is the best way to do it? Using span? Any other faster way? Thanks all, rui I think Sahgal is right, here is some code, perhaps it will help you. +(CGFloat)calculateDistanceBetweenSource:(CLLocationCoordinate2D)firstCoords andDestination:(CLLocationCoordinate2D)secondCoords { // this radius is in KM => if miles are needed it is calculated during

iPhone Brainstorm - CLLocation in Background - Polling every 15 minutes

对着背影说爱祢 提交于 2019-12-04 16:56:44
Here is the scenario. I need to have an application which polls a web service with the users location every 15 minutes whether in background / foreground. At the moment I: Start / Restart the location manager with accuracy highest and distance filter none. Wait to get within desired accurancy. Store reading setDesiredAccuracy to be: "kCLLocationAccuracyThreeKilometers" setDistanceFilter to be: 1000 Set a performSelector:@selector(getLocation) withObject:nil afterDelay:900 Start again from step 1. I want to make this the most battery saving method possible and would like to see what fellow