clgeocoder

Unable Return String from CLGeocoder reverseGeocodeLocation

牧云@^-^@ 提交于 2021-02-05 07:57:13
问题 I want to write a function to reverse geocode a location and assign the resulting string into a variable. Following this post i've got something like this: extension CLLocation { func reverseGeocodeLocation(completion: (answer: String?) -> Void) { CLGeocoder().reverseGeocodeLocation(self) { if let error = $1 { print("[ERROR] \(error.localizedDescription)") return } if let a = $0?.last { guard let streetName = a.thoroughfare, let postal = a.postalCode, let city = a.locality else { return }

Unable Return String from CLGeocoder reverseGeocodeLocation

﹥>﹥吖頭↗ 提交于 2021-02-05 07:56:26
问题 I want to write a function to reverse geocode a location and assign the resulting string into a variable. Following this post i've got something like this: extension CLLocation { func reverseGeocodeLocation(completion: (answer: String?) -> Void) { CLGeocoder().reverseGeocodeLocation(self) { if let error = $1 { print("[ERROR] \(error.localizedDescription)") return } if let a = $0?.last { guard let streetName = a.thoroughfare, let postal = a.postalCode, let city = a.locality else { return }

Setting MKMapView Zoom level to a locality

五迷三道 提交于 2020-01-04 03:46:00
问题 I wish to set the zoom level (OR set region) of MKMapView such that I can show a locality. Elaborating my context with an example. I have a location (CLLocation *) of which I found out the locality using CLGeocoder (reverse geocoding). Now, say the locality is 'Cupertino, CA' area. How do I find the region that completely encloses Cupertino in MKMapView? Thank you. 回答1: Create MKCoordinateRegion object and set map view region for that: CLLocationCoordinate2D location =

Setting MKMapView Zoom level to a locality

為{幸葍}努か 提交于 2020-01-04 03:45:22
问题 I wish to set the zoom level (OR set region) of MKMapView such that I can show a locality. Elaborating my context with an example. I have a location (CLLocation *) of which I found out the locality using CLGeocoder (reverse geocoding). Now, say the locality is 'Cupertino, CA' area. How do I find the region that completely encloses Cupertino in MKMapView? Thank you. 回答1: Create MKCoordinateRegion object and set map view region for that: CLLocationCoordinate2D location =

How to get the time zone name for a CLLocation

半城伤御伤魂 提交于 2020-01-02 20:12:24
问题 I have an application that uses a CLGeocoder to forwardGeocode a placemark from an address string. The CLPlacemark response contains a CLLocation which gives me GPS coordinates. The only way to create an NSTimeZone seems to be by using the correct Time Zone Name. It is important to point out that I am not using the current location of the device, so [NSTimeZone localTimeZone] will not work for me. Is there a way to get the timezone name for the CLLocation so that I can create an NSTimeZone

Waiting for CLGeocoder to finish on concurrent enumeration

左心房为你撑大大i 提交于 2020-01-02 09:55:46
问题 I have the following bit of code in a class method NSDictionary *shopAddresses = [[NSDictionary alloc] initWithContentsOfFile:fileName]; NSMutableArray *shopLocations = [NSMutableArray arrayWithCapacity:shopAddresses.count]; [shopAddresses enumerateKeysAndObjectsWithOptions:NSEnumerationConcurrent usingBlock:^(id key, ShopLocation *shopLocation, BOOL *stop) { CLGeocoder *geocoder = [[CLGeocoder alloc] init]; [geocoder geocodeAddressString:shopLocation.address completionHandler:^(NSArray

CLGeocoder returning locations in other countries

牧云@^-^@ 提交于 2020-01-01 08:45:17
问题 I have the following code: CLGeocoder *_geo = [[CLGeocoder alloc] init]; CLRegion *region = [[CLRegion alloc] initCircularRegionWithCenter: CLLocationCoordinate2DMake(37.33233141, -122.03121860) radius:100 identifier:@"San Francisco"]; [_geo geocodeAddressString:@"Starbucks" inRegion:region completionHandler:^(NSArray *placemarks, NSError *error) { NSLog("%@", placemarks); }]; This returns a Starbucks location in the Philippines even though the center is in the middle of San Francisco.

Saving Latitude and Longitude values to a MySQL Database iOS [closed]

巧了我就是萌 提交于 2019-12-25 18:24:53
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 7 years ago . I've set my code up so that the user inputs all of the location details (address, city, county, country and postcode) and then on the click of a button

get nearest locations from my current location

与世无争的帅哥 提交于 2019-12-25 11:35:40
问题 I am currently developing a mobile application for iOS which consists a part that requires to determine the users current location and from current location, i want to find nearest locations. Is there any way to implement this ?? I have done some coding for finding current location of user. here is my code snippet, CLGeocoder *geocoder = [[CLGeocoder alloc] init]; [geocoder reverseGeocodeLocation:locationManager.location completionHandler:^(NSArray *placemarks, NSError *error) { NSLog(@

get nearest locations from my current location

可紊 提交于 2019-12-25 11:32:07
问题 I am currently developing a mobile application for iOS which consists a part that requires to determine the users current location and from current location, i want to find nearest locations. Is there any way to implement this ?? I have done some coding for finding current location of user. here is my code snippet, CLGeocoder *geocoder = [[CLGeocoder alloc] init]; [geocoder reverseGeocodeLocation:locationManager.location completionHandler:^(NSArray *placemarks, NSError *error) { NSLog(@