0

Is it possible to add pins to map kit solely based on physical address or is there a way to get long and lat based on physical address

user1898829
  • 3,437
  • 6
  • 34
  • 62

1 Answers1

0

Yes, You can get lat long from the address. Please refer this answer : iOS - MKMapView place annotation by using address instead of lat / long

Basically it does this :

NSString *location = @"some address, state, and zip";
CLGeocoder *geocoder = [[CLGeocoder alloc] init];
            [geocoder geocodeAddressString:location 
                 completionHandler:^(NSArray* placemarks, NSError* error){
                     if (placemarks && placemarks.count > 0) {
                         CLPlacemark *topResult = [placemarks objectAtIndex:0];
                         MKPlacemark *placemark = [[MKPlacemark alloc] initWithPlacemark:topResult];

                         MKCoordinateRegion region = self.mapView.region;
                         region.center = placemark.region.center;
                         region.span.longitudeDelta /= 8.0;
                         region.span.latitudeDelta /= 8.0;

                         [self.mapView setRegion:region animated:YES];
                         [self.mapView addAnnotation:placemark];
                     }
                 }
             ];
Community
  • 1
  • 1
jithinroy
  • 1,885
  • 1
  • 16
  • 23