#import "MapStruct.h"
@synthesize mapTypeSegment, myMapView;
- (IBAction)maptypeChange
{
if(mapTypeSegment.selectedSegmentIndex == 0)
[myMapView setMapType:MKMapTypeStandard];
else if(mapTypeSegment.selectedSegmentIndex == 1)
[myMapView setMapType:MKMapTypeSatellite];
else if(mapTypeSegment.selectedSegmentIndex == 2)
[myMapView setMapType:MKMapTypeHybrid];
}
- (void)viewDidLoad
{
[super viewDidLoad];
myMapView.showsUserLocation = YES;
MKCoordinateRegion region;
region.center.latitude = 40.71435;
region.center.longitude = -74.00597;
//region.span.longitudeDelta = 1.5f;
//region.span.latitudeDelta = 0.5f;
[myMapView setRegion:region animated:YES];
MapStruct *msObj = [[MapStruct alloc] init];
msObj.title = @"New York";
msObj.subtitle = @"The City That Never Sleeps!";
msObj.coordinate = region.center;
[myMapView addAnnotation:(id)msObj];
//[myMapView selectAnnotation:(id)msObj animated:YES];
MKCoordinateRegion region2;
region2.center.latitude = 47.60621;
region2.center.longitude = -122.33207;
//region2.span.longitudeDelta = 0.5f;
//region2.span.latitudeDelta = 0.5f;
[myMapView setRegion:region2 animated:YES];
MapStruct *msObj2 = [[MapStruct alloc] init];
msObj2.title = @"Seattle";
msObj2.subtitle = @"Microsoft Headquarter.";
msObj2.coordinate = region2.center;
[myMapView addAnnotation:(id)msObj2];
//[myMapView selectAnnotation:(id)msObj2 animated:YES];
MKCoordinateRegion region3;
region3.center.latitude = 37.32300;
region3.center.longitude = -122.03218;
region3.span.longitudeDelta = 50.0f;
region3.span.latitudeDelta = 50.0f;
[myMapView setRegion:region3 animated:YES];
MapStruct *msObj3 = [[MapStruct alloc] init];
msObj3.title = @"Cupertino";
msObj3.subtitle = @"Apple Inc.";
msObj3.coordinate = region3.center;
[myMapView addAnnotation:(id)msObj3];
[myMapView selectAnnotation:(id)msObj3 animated:YES];
}
No comments:
Post a Comment
Comment