oscarimonbox
3/1/2016 - 4:03 PM

Obtener coordenadas Google desde dirección

Obtener coordenadas Google desde dirección

    [self.geocoder geocodeAddressString:self.tfPlaceLocation.text completionHandler:^(NSArray *placemarks, NSError *error) {
        
        
        if([placemarks count]){
            
            if (([placemarks count]) == 1) {
                
                CLPlacemark* place = [placemarks firstObject];
                [self.mapView animateToLocation:place.location.coordinate];
                
            } else {
                
                self.placemarksResult = [[NSArray alloc]init];
                self.placemarksResult = placemarks;
                
                UIActionSheet *popup = [[UIActionSheet alloc] initWithTitle:NSLocalizedString(@"General_SelectLocation", nil)
                                                                   delegate:self
                                                          cancelButtonTitle:NSLocalizedString(@"General_Cancel", nil)
                                                     destructiveButtonTitle:nil
                                                          otherButtonTitles:nil];
                
                int i=0;
                
                for( CLPlacemark *title in placemarks) {
                    AutoCompleteAddress* address = [AutoCompleteAddress new];
                    address.address = title;
                    
                    [popup addButtonWithTitle: [address autocompleteString]];
                    
                    i++;
                    if (i==3)
                        break;
                }
                
                popup.tag = 1;
                [popup showInView:self.view];
            }
            
        }
    }];