Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // MapViewController.m
- // CPOP Test 4
- //
- // Created by Will Kerswell on 03/10/2012.
- // Copyright (c) 2012 Will Kerswell. All rights reserved.
- //
- #import "MapViewController.h"
- #import "UIDevice+Resolutions.h"
- #import "DataBase.h"
- #import "MapViewController.h"
- @implementation MapViewController
- @synthesize showMapView;
- @synthesize mapSgementedControl;
- /////////////////////////////
- #pragma mark - Pin Display
- /////////////////////////////
- -(void)pins
- {
- //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.showMapView 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 {
- MKPinAnnotationView *pinView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:@"pinView"];
- if (!pinView) {
- pinView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"pinView"];
- pinView.pinColor = MKPinAnnotationColorRed;
- pinView.animatesDrop = YES;
- 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{
- NSLog(@"Pin button pressed");
- //myLabel.text=@"hi";
- }
- /////////////////////////////
- #pragma mark - Map Didplay
- /////////////////////////////
- - (IBAction)mapSize:(id)sender {
- //Chane between local and wide view.
- switch (self.mapSgementedControl.selectedSegmentIndex) {
- case 0:
- NSLog(@"Wide");
- [self wideMap];
- break;
- case 1:
- NSLog(@"Local");
- [self localMap];
- default:
- break;
- }
- }
- -(void)wideMap{
- //zooms the map out so the user can see the surrondings
- showMapView.mapType= MKMapTypeStandard;
- MKCoordinateRegion newRegion;
- newRegion.center.latitude = LAT_POSN ;
- newRegion.center.longitude = LON_POSN;
- newRegion.span.latitudeDelta = 0.181168;
- newRegion.span.longitudeDelta = 0.43911;
- [self.showMapView setRegion:newRegion animated:YES];
- }
- -(void) localMap{
- //zooms the user into the local view so they can see the ground.
- // [self.coord addObject:@"53.057801"];
- // [self.coord addObject:@"-2.68779504298"];
- // [self.coord addObject:@"0.011323"];
- // [self.coord addObject:@"53.057801"];
- showMapView.mapType= MKMapTypeStandard;
- MKCoordinateRegion newRegion;
- newRegion.center.latitude = 53.057801 ;
- newRegion.center.longitude = -2.68779504298;
- newRegion.span.latitudeDelta = 0.011323;
- newRegion.span.longitudeDelta = 0.027444;
- NSLog(@"%f",newRegion.center.latitude);
- NSLog(@"%f",newRegion.center.longitude);
- NSLog(@"%f",newRegion.span.latitudeDelta);
- NSLog(@"%f",newRegion.span.longitudeDelta);
- [self.showMapView setRegion:newRegion animated:YES];
- }
- /////////////////////////////
- #pragma mark - View Licfcycle
- /////////////////////////////
- - (void)viewDidLoad
- {
- //makes the top title black in the more or the tabbar view
- self.tabBarController.moreNavigationController.navigationBar.tintColor = [UIColor blackColor];
- //Test to see if the user is using an iPhone 5
- //This can be to change things depending on the screen size.
- if ([UIDevice deviceType] & iPhone5){
- NSLog(@"iPhone 5");
- }
- NSLog(@"This has run");
- //start map
- [self localMap];
- [super viewDidLoad];
- }
- //other lifecycle methods.
- - (void)didReceiveMemoryWarning
- {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- - (void)viewDidUnload {
- [super viewDidUnload];
- }
- - (void)tabBarController:(UITabBarController *)controller willBeginCustomizingViewControllers:(NSArray *)viewControllers {
- UIView *editView = [controller.view.subviews objectAtIndex:1];
- UINavigationBar *modalNavBar = [editView.subviews objectAtIndex:0];
- modalNavBar.tintColor = [UIColor blackColor];
- }
- @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement