MkMapView Zoom Level

Posted by meetS on Stack Overflow See other posts from Stack Overflow or by meetS
Published on 2010-04-26T10:09:39Z Indexed on 2010/04/26 10:13 UTC
Read the original article Hit count: 968

Filed under:
|
|

I m using MkMapView with google maps.I succeed to show map view and address with annotation pin.But I want increased zoom level.How Can I Set it programmatically??

  • (void) showMyAddress { //Hide the keypad MKCoordinateRegion region; MKCoordinateSpan span; span.latitudeDelta=0.2; span.longitudeDelta=0.2;

    CLLocationCoordinate2D location = [self addressLocation]; region.span=span; region.center=location;

    if(addAnnotation != nil) { [mapView removeAnnotation:addAnnotation]; [addAnnotation release]; addAnnotation = nil; }

    addAnnotation = [[AddAnnotation alloc] initWithCoordinate:location ]; [addAnnotation setMTitle:@"abc"]; [addAnnotation setMSubTitle:@"def."]

    [mapView addAnnotation:addAnnotation];

    [mapView setRegion:region animated:TRUE]; [mapView regionThatFits:region];

}

-(CLLocationCoordinate2D) addressLocation { NSString *urlString = [NSString stringWithFormat:@"http://maps.google.com/maps/geo?q=%@&output=csv", [@"abc" stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

NSString *locationString = [NSString stringWithContentsOfURL:[NSURL URLWithString:urlString] encoding:NSStringEncodingConversionAllowLossy  error:nil];
NSArray *listItems = [locationString componentsSeparatedByString:@","];

double latitude = 0.0;
double longitude = 0.0;

if([listItems count] >= 4 && [[listItems objectAtIndex:0] isEqualToString:@"200"]) {
    latitude = [[listItems objectAtIndex:2] doubleValue];
    longitude = [[listItems objectAtIndex:3] doubleValue];
}
else {

}
CLLocationCoordinate2D location;
location.latitude = latitude;
location.longitude = longitude;

return location;

}

© Stack Overflow or respective owner

Related posts about mkmapview

Related posts about iphone