cllocation

How To Call a func within a Closure

六月ゝ 毕业季﹏ 提交于 2019-12-04 06:40:54
问题 In a model's class Location , I get the name of the current city: var currentLatitude: Double! var currentLongitude: Double! var currentLocation: String! var currentCity: String! func getLocationName() { let geoCoder = CLGeocoder() let location = CLLocation(latitude: currentLatitude, longitude: currentLongitude) geoCoder.reverseGeocodeLocation(location, completionHandler: { placemarks, error in guard let addressDict = placemarks?[0].addressDictionary else { return } if let city = addressDict[

CLGeocoder reverse geocoding fails with Error Domain=NSURLErrorDomain Code=-1000 -

时光总嘲笑我的痴心妄想 提交于 2019-12-04 06:06:08
With a CLLocation object (content e.g. latitude = 48.196169, longitude = 11.620237), I try to get the current city and country like: if(!geocoder) { geocoder = [[CLGeocoder alloc] init]; } if (geocoder.geocoding) [geocoder cancelGeocode]; [geocoder reverseGeocodeLocation:lo completionHandler:^(NSArray *placemarks, NSError *error) { if(devMode) { NSLog(@"Found placemarks: %@, error: %@", placemarks, error); } if (error == nil && [placemarks count] > 0) { // MY CODE - here placemarks is always (null) } else { if(devMode) NSLog(@"%@", error.debugDescription); } }]; mostly, that works great. But

How to get lat and long coordinates from address string

♀尐吖头ヾ 提交于 2019-12-04 03:27:36
I have a MKMapView that has a UISearchBar on the top, and I want the user to be able to type a address, and to find that address and drop a pin on it. What I don't know is how to turn the address string into longitude and latitude, so I can make a CLLocation object. Does anyone know how I can do this? arjavlad You may find your answer in this question. iOS - MKMapView place annotation by using address instead of lat / long By User Romes. NSString *location = @"some address, state, and zip"; CLGeocoder *geocoder = [[CLGeocoder alloc] init]; [geocoder geocodeAddressString:location

Convert String to CLLocationCoordinate2D in swift

冷暖自知 提交于 2019-12-04 00:42:50
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.value["longitude"] as? String let ID = snapshot.value["ID"] as? String println("\(MomentaryLatitude)")

converting a CLLocationCoordinate2D type to number or string

无人久伴 提交于 2019-12-03 16:43:54
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", centerCoord.longitude]; NSLog("User's latitude is: %@", tmpLat); NSLog("User's longitude is: %@",

How can I evaluate the GPS signal strength? (iPhone)

廉价感情. 提交于 2019-12-03 12:59:24
问题 I need a way of categorising the strength of the GPS signal. So far I have come across the horizontalAccuracy property of CLLocation (Class Reference). To be more specific I need to create something like the following; the issue I'm having is filling in the if statements. if (someLocation.horizontalAccuracy ...) { // No Signal } else if (someLocation.horizontalAccuracy ...) { // Poor Signal } else if (someLocation.horizontalAccuracy ...) { // Average Signal } else if (someLocation

cllocation and mkreversegeocoder

烂漫一生 提交于 2019-12-03 10:19:31
问题 i'm try to retreiving city name with cllocation and mkreversegeocoder. in my viewdidload method i istance cllocationmanager: self.locManager = [[CLLocationManager alloc] init]; locManager.delegate = self; locManager.desiredAccuracy = kCLLocationAccuracyBest; [locManager startUpdatingLocation]; and after: - (void) locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { //some code to retrieve my information

CLLocationCoordinate2D without knowing how many will be in the array?

萝らか妹 提交于 2019-12-03 09:51:33
问题 I need to build an array using something like the following: CLLocationCoordinate2D points[4]; points[0] = CLLocationCoordinate2DMake(41.000512, -109.050116); points[1] = CLLocationCoordinate2DMake(41.002371, -102.052066); points[2] = CLLocationCoordinate2DMake(36.993076, -102.041981); points[3] = CLLocationCoordinate2DMake(36.99892, -109.045267); Problem is, I will never know how many items are going to be in the array, so I can specify the count. Is there a way to create a

Distance between Long Lat coord using SQLITE

六眼飞鱼酱① 提交于 2019-12-03 03:48:28
I've got an sqlite db with long and lat of shops and I want to find out the closest 5 shops. So the following code works fine. if(sqlite3_prepare_v2(db, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) { while (sqlite3_step(compiledStatement) == SQLITE_ROW) { NSString *branchStr = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 0)]; NSNumber *fLat = [NSNumber numberWithFloat:(float)sqlite3_column_double(compiledStatement, 1)]; NSNumber *fLong = [NSNumber numberWithFloat:(float)sqlite3_column_double(compiledStatement, 2)]; NSLog(@"Address %@, Lat = %@,

How can I evaluate the GPS signal strength? (iPhone)

亡梦爱人 提交于 2019-12-03 03:13:21
I need a way of categorising the strength of the GPS signal. So far I have come across the horizontalAccuracy property of CLLocation ( Class Reference ). To be more specific I need to create something like the following; the issue I'm having is filling in the if statements. if (someLocation.horizontalAccuracy ...) { // No Signal } else if (someLocation.horizontalAccuracy ...) { // Poor Signal } else if (someLocation.horizontalAccuracy ...) { // Average Signal } else if (someLocation.horizontalAccuracy ...) { // Good Signal } else { // Excellent Signal } Please can someone assist me in this? I