clgeocoder

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

CLGeocoder reverseGeocodeLocation “kCLErrorDomain error 2”

大兔子大兔子 提交于 2019-12-12 14:13:38
问题 I'm developing an iOS app with reverse geocoding features. When I call the function the first time everything is fine. After the second call (with a new instance of the controller where the call is done) the "Domain=kCLErrorDomain Code=2" Error appears. This happens on the Simulator and on the device. The Coordinates are valid. My Code: CLGeocoder *geoCoder = [[CLGeocoder alloc] init]; CLLocation *loc = [[CLLocation alloc] initWithLatitude:cityCoords.latitude longitude:cityCoords.longitude];

geocoder.geocodeAddressString no longer works with swift update today

风格不统一 提交于 2019-12-12 12:18:34
问题 https://developer.apple.com/library/prerelease/mac/releasenotes/General/APIDiffsMacOSX10_11/Swift/CoreLocation.html shows that there were a couple of changes func geocodeAddressString(_ addressString: String!, completionHandler completionHandler: CLGeocodeCompletionHandler!) to: func geocodeAddressString(_ addressString: String, completionHandler completionHandler: CLGeocodeCompletionHandler) my code was: var geocoder = CLGeocoder() geocoder.geocodeAddressString("\(event!.street), \(event!

CLPlacemark crash in Swift

*爱你&永不变心* 提交于 2019-12-11 03:22:19
问题 I'm using CLGeocoder for reverse geolocation and get array of CLPlacemark . When I use GPS outside the US (i.e. -27,127) and then access placemark.postalCode , the app crashes with: "fatal error: unexpectedly found nil while unwrapping an Optional value". It seems, that placemark.postalCode is nil where no postal code is available. But postalCode return type in Swift is String! : var postalCode: String! { get } // zip code, eg. 95014 So I can't even test is for nil , because the crash is

CLPlacemark.locality, value changes if the device language is different

て烟熏妆下的殇ゞ 提交于 2019-12-08 23:58:24
问题 I uses CLGeocoder to decode the CLLocation from longitude/latitude to place names. It works fine. But there is still one thing bothers me. When i set the device language to English, the result of the code below: - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation{ /* We received the new location */ NSLog(@"Latitude = %f", newLocation.coordinate.latitude); NSLog(@"Longitude = %f", newLocation.coordinate

Crash in Geocode call

一个人想着一个人 提交于 2019-12-08 06:40:52
问题 In using CLGeocoder I get a crash (EXC_BAD_ACCESS) right after the let placemark ... in the closure success part which I don't understand. I am testing and may have made tried to access the server many times. Or do I need to make the call in a background thread? import UIKit import CoreLocation class ViewController: UIViewController { var destinationPlacemark = CLPlacemark() override func viewDidLoad() { super.viewDidLoad() forwardGeocoding(address: "Infinite Loop, Cupertino, CA 95014") }

How to get the time zone name for a CLLocation

て烟熏妆下的殇ゞ 提交于 2019-12-06 10:41:50
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 correctly? NOTE: I have been using timeZoneForSecondsFromGMT but that never contains correct DST data, so

Waiting for CLGeocoder to finish on concurrent enumeration

无人久伴 提交于 2019-12-06 04:27:35
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 *placemarks, NSError *error) { if (error) { NSLog(@"Geocode failed with error: %@", error); } else {

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

不问归期 提交于 2019-12-06 00:44:01
问题 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

CLPlacemark - State Abbreviations?

旧街凉风 提交于 2019-12-05 10:31:55
问题 I was wondering if it was possible to get the state abbreviations from CLPlacemark? In the CLPlacemark Reference from Apple it states: administrativeArea The state or province associated with the placemark. (read-only) @property(nonatomic, readonly) NSString *administrativeArea Discussion If the placemark location is Apple’s headquarters, for example, the value for this property would be the string “CA” or “California”. but whenever I use it, I only get the full state (i.e California) and not