I have the map currently working when the user click on the buttons.
How can I zoom into the map and possibly animate as it xooms in, when the user click on the buttons.
Here are hte main files and the header files. Also, how can i show my current location?
Thanks in advance
main file
@synthesize map;
//Add Map overlay
-(MKOverlayView*)mapView:(MKMapView *)mapView viewForOverlay:(id<MKOverlay>)overlay{
MKCircleView* circleView =[[MKCircleView alloc] initWithOverlay:overlay];
circleView.strokeColor = [UIColor blueColor];
circleView.fillColor = [UIColor redColor];
return circleView;
}
-(IBAction)onLocationButtonTop:(id)sender {
UIBarButtonItem* b = (UIBarButtonItem*) sender;
int tag = b.tag;
float latitude = 40.0;
float longitude = -75.0;
if(tag == 1){
latitude = 57.15;longitude = -2.15;
}
else if(tag == 2){
latitude = 39.91;longitude = 116.41;
}
else{
latitude = -1.46;longitude = -48.48;
}
CLLocationCoordinate2D x;
x.latitude = latitude;
x.longitude = longitude;
MKCoordinateSpan z;
z.latitudeDelta = 0.25;
z.longitudeDelta = 0.25;
MKCoordinateRegion y;
y.center = x;
y.span = z;
map.region = y;
[map addOverlay:[MKCircle circleWithCenterCoordinate:x
radius:1000]];
}
h file
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
@interface MapExampleK2ViewController : UIViewController <MKMapViewDelegate>
@property (strong,nonatomic) IBOutlet MKMapView* map;
-(IBAction)onLocationButtonTop:(id)sender;
@end
For second part of your question You can use CLLocationManager to get you current location and then use setRegion when the location updates. You can refer to region code posted on http://developer.apple.com/library/ios/#samplecode/Regions/Introduction/Intro.html#//apple_ref/doc/uid/DTS40010726.
Below is the function from that code that is setting focus on the map to your current location.