Tuesday 5 August 2014

Show Coordinate on Map View

CLLocationCoordinate2D _coordinate = CLLocationCoordinate2DMake(37.3104, -122.0108);

    MKCoordinateRegion extentsRegion = MKCoordinateRegionMakeWithDistance(_coordinate, 50, 50);
    
    
    extentsRegion.span.latitudeDelta = 0.02f;
    
    extentsRegion.span.longitudeDelta = 0.02f;
    
    extentsRegion.center = _coordinate;
    
    [self.myMapView setRegion:extentsRegion animated:YES];
    
    
    //set annotation
    MKPointAnnotation *annotation = [[MKPointAnnotation alloc]init];
    
    NSString *sttt = [[NSString alloc]initWithFormat:@"%f,%f",_coordinate.latitude,_coordinate.longitude];
    
    
    
    
    annotation.title = [NSString stringWithFormat:@"%@",address];
    annotation.subtitle = sttt;
    
    annotation.coordinate = _coordinate;
    

    [self.myMapView addAnnotation:annotation];

No comments:

Post a Comment