Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #import "ApplicationViewController.h"
- @interface ApplicationViewController ()
- @end
- @implementation ApplicationViewController
- @synthesize mapView;
- @synthesize myLabel;
- - (void)viewDidLoad
- {
- [self goLocation];
- [super viewDidLoad];
- }
- -(void) goLocation{
- //Create region
- mapView.mapType= MKMapTypeSatellite;
- MKCoordinateRegion newRegion;
- newRegion.center.latitude = 51.484864 ;
- newRegion.center.longitude = -2.76013;
- newRegion.span.latitudeDelta = 0.001149;
- newRegion.span.longitudeDelta = 0.002411;
- [self.mapView setRegion:newRegion animated:YES];
- //Set coordinates of pin
- CLLocationCoordinate2D coordinate;
- coordinate.latitude = 51.484864;
- coordinate.longitude = -2.76013;
- //Create Pin
- MKPointAnnotation *annotation = [[MKPointAnnotation alloc] init];
- [annotation setCoordinate:coordinate];
- [annotation setTitle:@"The Office"];
- [annotation setSubtitle:@"Here is where we do all our work!"];
- // Add pin to map
- [self.mapView addAnnotation:annotation];
- //This will allow you to open up safari when the button is pressed:
- //[[UIApplication sharedApplication] openURL:[NSURL URLWithString: @"URL goes here"]];
- }
- - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
- MKAnnotationView *pinView = (MKAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:@"try"];
- if (!pinView) {
- pinView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"try"];
- pinView.canShowCallout = YES;
- pinView.image = [UIImage imageNamed:@"1.png"];
- pinView.canShowCallout = YES;
- UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
- pinView.rightCalloutAccessoryView = rightButton;
- } else {
- pinView.annotation = annotation;
- }
- return pinView;
- }
- //IMPLEMENT THIS ONE (WHEN DISCLOSURE BUTTON IS PRESSED):
- - (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control{
- myLabel.text=@"hi";
- }
- - (void)didReceiveMemoryWarning
- {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- - (void)viewDidUnload {
- [self setMapView:nil];
- [self setMyLabel:nil];
- [super viewDidUnload];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement