Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 22nd, 2012  |  syntax: None  |  size: 2.00 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Issue forward-geocoding multiple addresses
  2. - (void)processProperties:(Property *)property {
  3.  
  4.     [geocoder geocodeAddressString:property.postalCode
  5.                  completionHandler:^(NSArray* placemarks, NSError* error){
  6.                      placemark = [placemarks lastObject];
  7.                      for (CLPlacemark* aPlacemark in placemarks)
  8.                      {
  9.                          [sublet setLatitude:aPlacemark.location.coordinate.latitude];
  10.                          [sublet setLongitude:aPlacemark.location.coordinate.longitude];  
  11.                      }
  12.                  }];
  13. }
  14.  
  15.  
  16. - (void)addAnnotations:(NSArray *)objects {
  17.     CLLocationDegrees lat;
  18.     CLLocationDegrees longitude;
  19.     CLLocationCoordinate2D mCoords;
  20.     NSString *fullAddress;
  21.  
  22.     // Add the annotations found nearby
  23.     for (Property *property in objects) {
  24.  
  25.         [self processProperties:property];
  26.         lat = property.latitude;
  27.         longitude = property.longitude;
  28.  
  29.         fullAddress = [NSString stringWithFormat:@"%@ %@ %@", property.houseNumber, @" ", property.streetName];
  30.         [self createAnnotationWithCoords:mCoords :fullAddress :[NSString stringWithFormat:@"$%.2f", property.rent]];
  31.     }
  32.     zoomLevel = 0.1;
  33.     mCoords = CLLocationCoordinate2DMake(lat,longitude);
  34.     MKCoordinateRegion region = MKCoordinateRegionMake(mCoords,MKCoordinateSpanMake(zoomLevel,zoomLevel));
  35.  
  36.    [self.mapView setRegion:region animated:YES];
  37. }
  38.        
  39. - (void)processProperties:(Property *)property {
  40. CLGeocoder *geocoder = [[CLGeocoder alloc] init];
  41. [geocoder geocodeAddressString:property.postalCode
  42.              completionHandler:^(NSArray* placemarks, NSError* error){
  43.                  placemark = [placemarks lastObject];
  44.                  for (CLPlacemark* aPlacemark in placemarks)
  45.                  {
  46.                      [sublet setLatitude:aPlacemark.location.coordinate.latitude];
  47.                      [sublet setLongitude:aPlacemark.location.coordinate.longitude];  
  48.                  }
  49.                  [geocoder release];
  50.              }];
  51.   }