- Issue forward-geocoding multiple addresses
- - (void)processProperties:(Property *)property {
- [geocoder geocodeAddressString:property.postalCode
- completionHandler:^(NSArray* placemarks, NSError* error){
- placemark = [placemarks lastObject];
- for (CLPlacemark* aPlacemark in placemarks)
- {
- [sublet setLatitude:aPlacemark.location.coordinate.latitude];
- [sublet setLongitude:aPlacemark.location.coordinate.longitude];
- }
- }];
- }
- - (void)addAnnotations:(NSArray *)objects {
- CLLocationDegrees lat;
- CLLocationDegrees longitude;
- CLLocationCoordinate2D mCoords;
- NSString *fullAddress;
- // Add the annotations found nearby
- for (Property *property in objects) {
- [self processProperties:property];
- lat = property.latitude;
- longitude = property.longitude;
- fullAddress = [NSString stringWithFormat:@"%@ %@ %@", property.houseNumber, @" ", property.streetName];
- [self createAnnotationWithCoords:mCoords :fullAddress :[NSString stringWithFormat:@"$%.2f", property.rent]];
- }
- zoomLevel = 0.1;
- mCoords = CLLocationCoordinate2DMake(lat,longitude);
- MKCoordinateRegion region = MKCoordinateRegionMake(mCoords,MKCoordinateSpanMake(zoomLevel,zoomLevel));
- [self.mapView setRegion:region animated:YES];
- }
- - (void)processProperties:(Property *)property {
- CLGeocoder *geocoder = [[CLGeocoder alloc] init];
- [geocoder geocodeAddressString:property.postalCode
- completionHandler:^(NSArray* placemarks, NSError* error){
- placemark = [placemarks lastObject];
- for (CLPlacemark* aPlacemark in placemarks)
- {
- [sublet setLatitude:aPlacemark.location.coordinate.latitude];
- [sublet setLongitude:aPlacemark.location.coordinate.longitude];
- }
- [geocoder release];
- }];
- }