clgeocoder

Set address string with reverseGeocodeLocation: and return from method

泪湿孤枕 提交于 2019-11-28 02:17:09
问题 I'm try to localize a start and end point to an address string, so that I can store it into NSUserDefaults . The problem is that the method continues executing and does not set my variable. NSLog(@"Begin"); __block NSString *returnAddress = @""; [self.geoCoder reverseGeocodeLocation:self.locManager.location completionHandler:^(NSArray *placemarks, NSError *error) { if(error){ NSLog(@"%@", [error localizedDescription]); } CLPlacemark *placemark = [placemarks lastObject]; startAddressString =

CLGeocoder returns wrong results when city name is equal to some country's name (and not only)

老子叫甜甜 提交于 2019-11-27 23:37:27
问题 In one of my apps I need to add an ability to find a city by its name. I am using CLGeocoder to achieve this and I want it to have a behaviour identical to iOS weather app. Below is the code which I have: CLGeocoder().geocodeAddressString(searchBar.text!, completionHandler:{ (placemarks, error) -> Void in guard let nonNilMarks = placemarks else {return} for placemark in nonNilMarks { print("locality: \(placemark.locality)") print("name: \(placemark.name)") print("country: \(placemark.country)

Convert coordinates to City name?

旧巷老猫 提交于 2019-11-27 17:23:34
How to get an address from coordinates using MapKit? I have this code when long press on the map it gets the coordinates: func didLongPressMap(sender: UILongPressGestureRecognizer) { if sender.state == UIGestureRecognizerState.Began { let touchPoint = sender.locationInView(self.mapView) let touchCoordinate = self.mapView.convertPoint(touchPoint, toCoordinateFromView: self.mapView) var annotation = MKPointAnnotation() annotation.coordinate = touchCoordinate annotation.title = "Your position" self.mapView.addAnnotation(annotation) //drops the pin println("lat: \(touchCoordinate.latitude)") var

iPhone iOS5 CLGeocoder how to geocode a large (200) set of addresses?

故事扮演 提交于 2019-11-27 14:09:56
问题 I got a large set of about 200 addresses for which I need to know their latitude and longitude. I've created a method that parses the addresses, and now I'm trying to get coordinates for these addresses using CLGeocoder . My current approach is to create geocoders in parallel and let them do their magic. I noticed that each one of them seems to take a separate thread. (so I saw up to 100 threads at one point). The problem that I'm running into is that at some point (after about 50 addresses),

Multiple Locations on Map (using MKMapItem and CLGeocoder)

末鹿安然 提交于 2019-11-27 08:47:29
I'm trying to display multiple locations in MKMapItem . I am getting those locations from a CLGeocoder , unfortunately it only accepts one location. Even though I pass in an NSArray it just returns one location. The following works fine with a single location, but not with multiple locations. How can I geocode multiple locations? Class mapItemClass = [MKMapItem class]; if (mapItemClass && [mapItemClass respondsToSelector:@selector(openMapsWithItems:launchOptions:)]) { NSArray *addresses = @[@"Mumbai",@"Delhi","Banglore"]; CLGeocoder *geocoder = [[CLGeocoder alloc] init]; [geocoder

kCLErrorDomain error 2 after geocoding repeatedly with CLGeocoder

ε祈祈猫儿з 提交于 2019-11-27 03:47:45
问题 I have a search bar in my application that the user can type an address into, and it will come up with the geocoded result. The result updates as the user types, according to the following code: - (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText { ... if (self.geocoder.geocoding) [self.geocoder cancelGeocode]; [self.geocoder geocodeAddressString:searchText completionHandler:^(NSArray *placemarks, NSError *error) { if (error != nil) { NSLog(@"ERROR during geocode:

Multiple Locations on Map (using MKMapItem and CLGeocoder)

删除回忆录丶 提交于 2019-11-26 14:20:00
问题 I'm trying to display multiple locations in MKMapItem . I am getting those locations from a CLGeocoder , unfortunately it only accepts one location. Even though I pass in an NSArray it just returns one location. The following works fine with a single location, but not with multiple locations. How can I geocode multiple locations? Class mapItemClass = [MKMapItem class]; if (mapItemClass && [mapItemClass respondsToSelector:@selector(openMapsWithItems:launchOptions:)]) { NSArray *addresses = @[@