clgeocoder

get nearest locations from my current location

安稳与你 提交于 2019-12-25 11:32:06
问题 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(@

How to get multiple placemarks from CLGeocoder

笑着哭i 提交于 2019-12-23 09:04:05
问题 Whatever address i give to the geocoder ([geocoder geocodeAddressString:completionHandler:), it always puts only one object in the placemarks array. I there any way to get multiple results (like in Maps app) from which the user can select one? 回答1: I've done some sniffing on the packets and it seems that CLGeocoder doesn't connect to Google's geocoding service, but to Apple's. I've also noticed that I get only one placemark from there every time. If you want something more sophisticated you

Reverse geocoding from given coordinates (not current location, but manually provided)

坚强是说给别人听的谎言 提交于 2019-12-23 02:58:09
问题 I am fetching GPS information of all my images and they are stored in a Dictionary. I would pass on the lat & long values from this dictionary to the reverseGeocodeLocation function call & store the results in my database. The problem here is that this function is an asynchronous call & I need to synchronize the whole process for my record to get inserted into the table. Eg: My array read following coordinates: 32.77003,96.87532. It now calls the reverseGeocodeLocation function, passing on

Convert GPS coordinates to a city name / address in Swift

邮差的信 提交于 2019-12-22 05:25:09
问题 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

Convert GPS coordinates to a city name / address in Swift

自作多情 提交于 2019-12-22 05:25:03
问题 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

iOS Swift - CLGeocoder completionHandler block

你离开我真会死。 提交于 2019-12-19 04:57:07
问题 I'm trying to parse a location (CLLocation) into a String. func locationToString (currentLocation: CLLocation) -> String? { var whatToReturn: String? CLGeocoder().reverseGeocodeLocation(currentLocation, completionHandler: { (placemarks: [AnyObject]!, error: NSError!) in if error == nil && placemarks.count > 0 { let location = placemarks[0] as CLPlacemark whatToReturn = "\(location.locality) \(location.thoroughfare) \(location.subThoroughfare)" } }) return whatToReturn } Obviously,

Forward Geocode Example using CLGeocoder

和自甴很熟 提交于 2019-12-19 03:54:33
问题 A directions to a working example or some guidance on how to use the forward geocoding beside the Apple Documentation. Thats pretty generic (i cant understand) Please this would be great! Also does anyone know if they are using Google API to achieve the same or their own? 回答1: Found this to work, though i will post it here if someone else finds it useful. CLGeocoder *geocoder = [[CLGeocoder alloc] init]; [geocoder geocodeAddressString:PlaceName.text completionHandler:^(NSArray *placemarks,

How to get formatted address NSString from AddressDictionary?

本秂侑毒 提交于 2019-12-18 04:34:07
问题 Trying to get formatted address from AddressDictionary, that I got from CLGeocoder. Used following code with no result: subtitle = [NSString stringWithString:[[addressDict objectForKey:@"FormattedAddressLines"]objectAtIndex:0]]; Also tried: subtitle = [[[ABAddressBook sharedAddressBook] formattedAddressFromDictionary:placemark.addressDictionary] string]; but this code seems working on Mac OS X only. Compiler asks about ABAdressBook, but I have both header files imported. #import <AddressBook

Convert coordinates to City name?

不羁岁月 提交于 2019-12-17 15:21:49
问题 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"

CLGeocoder in Swift - unable to return string when using reverseGeocodeLocation

我的梦境 提交于 2019-12-14 00:15:52
问题 I'm attempting to use CLGeocoder to return the location of coordinates in a string. My code currently looks like this: func getPlaceName(latitude: Double, longitude: Double) -> String { let coordinates = CLLocation(latitude: latitude, longitude: longitude) var answer = "" CLGeocoder().reverseGeocodeLocation(coordinates, completionHandler: {(placemarks, error) -> Void in if (error != nil) { println("Reverse geocoder failed with an error" + error.localizedDescription) answer = "" } if