Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to find Latitude and Longitude from Address in iPhone
    primarykey
    data
    text
    <p>I am making one application in which i am getting the address, i need to find the latitude and longitude from that address and show the place in map</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; [mapView setMapType:MKMapTypeStandard]; [mapView setZoomEnabled:YES]; [mapView setScrollEnabled:YES]; mapView.showsUserLocation = YES; MKCoordinateRegion region = { {0.0, 0.0 }, { 0.0, 0.0 } }; geoCoder.delegate = self; [geoCoder start]; double latitude = 0, longitude = 0; region.center.latitude = latitude; region.center.longitude = longitude; region.span.longitudeDelta = 0.01f; region.span.latitudeDelta = 0.01f; [mapView setRegion:region animated:YES]; [mapView setDelegate:self]; DisplayMap *ann = [[DisplayMap alloc] init]; ann.title = @"BarRestaurant"; ann.subtitle = @"..."; ann.coordinate = region.center; [mapView addAnnotation:ann]; } -(MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation: (id &lt;MKAnnotation&gt;)annotation { MKPinAnnotationView *pinView = nil; if(annotation != mapView.userLocation) { static NSString *defaultPinID = @"com.invasivecode.pin"; pinView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID]; if ( pinView == nil ) pinView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:defaultPinID] autorelease]; pinView.pinColor = MKPinAnnotationColorRed; pinView.canShowCallout = YES; pinView.animatesDrop = YES; } else { [mapView.userLocation setTitle:@"I am here"]; } return pinView; } - (CLLocationCoordinate2D) geoCodeUsingAddress:(NSString *)address { appRestaurantAppDelegate *delegate = [[UIApplication sharedApplication] delegate]; double latitude = 0, longitude = 0; address = delegate.streetName; NSString *esc_addr = [address stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSString *req = [NSString stringWithFormat:@"http://maps.google.com/maps/api/geocode/json?sensor=false&amp;address=%@", esc_addr]; NSString *result = [NSString stringWithContentsOfURL:[NSURL URLWithString:req] encoding:NSUTF8StringEncoding error:NULL]; if (result) { NSScanner *scanner = [NSScanner scannerWithString:result]; if ([scanner scanUpToString:@"\"lat\":" intoString:nil] &amp;&amp; [scanner scanString:@"\"lat\":" intoString:nil]) { [scanner scanDouble:&amp;latitude]; if ([scanner scanUpToString:@"\"lng\":" intoString:nil] &amp;&amp; [scanner scanString:@"\"lng\":" intoString:nil]) { [scanner scanDouble:&amp;longitude]; } } } CLLocationCoordinate2D center; center.latitude = latitude; center.longitude = longitude; return center; } </code></pre> <p>however i am unable to find the latitude and longitude please help me where i am doing wrong in the delegate i am getting the address from web server</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload