Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added map view controller

  • Loading branch information...
commit 31197b06218bfb736be27f21f03334e5ab342184 1 parent 36fa605
@blacker authored
View
22 MapAppDelegate.h
@@ -0,0 +1,22 @@
+//
+// MapAppDelegate.h
+// Map
+//
+// Created by Benjamin Lacker on 4/20/12.
+// Copyright 2012 __MyCompanyName__. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@class STFirstViewController;
+
+@interface MapAppDelegate : NSObject <UIApplicationDelegate> {
+ UIWindow *window;
+ STFirstViewController *viewController;
+}
+
+@property (nonatomic, retain) IBOutlet UIWindow *window;
+@property (nonatomic, retain) IBOutlet STFirstViewController *viewController;
+
+@end
+
View
BIN  ...odeproj/project.xcworkspace/xcuserdata/blacker.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown
View
21 Sethoscope.xcodeproj/xcuserdata/blacker.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Bucket
+ type = "1"
+ version = "1.0">
+ <FileBreakpoints>
+ <FileBreakpoint
+ shouldBeEnabled = "No"
+ ignoreCount = "0"
+ continueAfterRunningActions = "No"
+ isPathRelative = "1"
+ filePath = "Sethoscope/STFirstViewController.h"
+ timestampString = "356725233.296126"
+ startingColumnNumber = "9223372036854775807"
+ endingColumnNumber = "9223372036854775807"
+ startingLineNumber = "13"
+ endingLineNumber = "13"
+ landmarkName = "@interface STFirstViewController"
+ landmarkType = "2">
+ </FileBreakpoint>
+ </FileBreakpoints>
+</Bucket>
View
84 Sethoscope.xcodeproj/xcuserdata/blacker.xcuserdatad/xcschemes/Sethoscope.xcscheme
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Scheme
+ version = "1.3">
+ <BuildAction
+ parallelizeBuildables = "YES"
+ buildImplicitDependencies = "YES">
+ <BuildActionEntries>
+ <BuildActionEntry
+ buildForTesting = "YES"
+ buildForRunning = "YES"
+ buildForProfiling = "YES"
+ buildForArchiving = "YES"
+ buildForAnalyzing = "YES">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "8DCBD62515432E0200F72E61"
+ BuildableName = "Sethoscope.app"
+ BlueprintName = "Sethoscope"
+ ReferencedContainer = "container:Sethoscope.xcodeproj">
+ </BuildableReference>
+ </BuildActionEntry>
+ </BuildActionEntries>
+ </BuildAction>
+ <TestAction
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
+ shouldUseLaunchSchemeArgsEnv = "YES"
+ buildConfiguration = "Debug">
+ <Testables>
+ </Testables>
+ <MacroExpansion>
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "8DCBD62515432E0200F72E61"
+ BuildableName = "Sethoscope.app"
+ BlueprintName = "Sethoscope"
+ ReferencedContainer = "container:Sethoscope.xcodeproj">
+ </BuildableReference>
+ </MacroExpansion>
+ </TestAction>
+ <LaunchAction
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
+ launchStyle = "0"
+ useCustomWorkingDirectory = "NO"
+ buildConfiguration = "Debug"
+ debugDocumentVersioning = "YES"
+ allowLocationSimulation = "YES">
+ <BuildableProductRunnable>
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "8DCBD62515432E0200F72E61"
+ BuildableName = "Sethoscope.app"
+ BlueprintName = "Sethoscope"
+ ReferencedContainer = "container:Sethoscope.xcodeproj">
+ </BuildableReference>
+ </BuildableProductRunnable>
+ <AdditionalOptions>
+ </AdditionalOptions>
+ </LaunchAction>
+ <ProfileAction
+ shouldUseLaunchSchemeArgsEnv = "YES"
+ savedToolIdentifier = ""
+ useCustomWorkingDirectory = "NO"
+ buildConfiguration = "Release"
+ debugDocumentVersioning = "YES">
+ <BuildableProductRunnable>
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "8DCBD62515432E0200F72E61"
+ BuildableName = "Sethoscope.app"
+ BlueprintName = "Sethoscope"
+ ReferencedContainer = "container:Sethoscope.xcodeproj">
+ </BuildableReference>
+ </BuildableProductRunnable>
+ </ProfileAction>
+ <AnalyzeAction
+ buildConfiguration = "Debug">
+ </AnalyzeAction>
+ <ArchiveAction
+ buildConfiguration = "Release"
+ revealArchiveInOrganizer = "YES">
+ </ArchiveAction>
+</Scheme>
View
22 Sethoscope.xcodeproj/xcuserdata/blacker.xcuserdatad/xcschemes/xcschememanagement.plist
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>SchemeUserState</key>
+ <dict>
+ <key>Sethoscope.xcscheme</key>
+ <dict>
+ <key>orderHint</key>
+ <integer>0</integer>
+ </dict>
+ </dict>
+ <key>SuppressBuildableAutocreation</key>
+ <dict>
+ <key>8DCBD62515432E0200F72E61</key>
+ <dict>
+ <key>primary</key>
+ <true/>
+ </dict>
+ </dict>
+</dict>
+</plist>
View
85 Sethoscope/MapAppDelegate.m
@@ -0,0 +1,85 @@
+//
+// MapAppDelegate.m
+// Map
+//
+// Created by Benjamin Lacker on 4/20/12.
+// Copyright 2012 __MyCompanyName__. All rights reserved.
+//
+
+#import "MapAppDelegate.h"
+#import "STFirstViewController.h"
+
+@implementation MapAppDelegate
+
+@synthesize window;
+@synthesize viewController;
+
+
+#pragma mark -
+#pragma mark Application lifecycle
+
+- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
+
+ // Override point for customization after application launch.
+
+ // Add the view controller's view to the window and display.
+ [self.window addSubview:viewController.view];
+ [self.window makeKeyAndVisible];
+
+ return YES;
+}
+
+
+- (void)applicationWillResignActive:(UIApplication *)application {
+ /*
+ Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
+ Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
+ */
+}
+
+
+- (void)applicationDidEnterBackground:(UIApplication *)application {
+ /*
+ Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
+ If your application supports background execution, called instead of applicationWillTerminate: when the user quits.
+ */
+}
+
+
+- (void)applicationWillEnterForeground:(UIApplication *)application {
+ /*
+ Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background.
+ */
+}
+
+
+- (void)applicationDidBecomeActive:(UIApplication *)application {
+ /*
+ Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
+ */
+}
+
+
+- (void)applicationWillTerminate:(UIApplication *)application {
+ /*
+ Called when the application is about to terminate.
+ See also applicationDidEnterBackground:.
+ */
+}
+
+
+#pragma mark -
+#pragma mark Memory management
+
+- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
+ /*
+ Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later.
+ */
+}
+
+
+- (void)dealloc {
+}
+
+
+@end
View
24 Sethoscope/MapViewAnnotation.h
@@ -0,0 +1,24 @@
+//
+// MapViewAnnotation.h
+// Map
+//
+// Created by Benjamin Lacker on 4/20/12.
+// Copyright 2012 __MyCompanyName__. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import <MapKit/MapKit.h>
+
+@interface MapViewAnnotation : NSObject <MKAnnotation> {
+
+ NSString *title;
+ CLLocationCoordinate2D coordinate;
+
+}
+
+@property (nonatomic, copy) NSString *title;
+@property (nonatomic, readonly) CLLocationCoordinate2D coordinate;
+
+- (id)initWithTitle:(NSString *)ttl andCoordinate:(CLLocationCoordinate2D)c2d;
+
+@end
View
27 Sethoscope/MapViewAnnotation.m
@@ -0,0 +1,27 @@
+//
+// MapViewAnnotation.m
+// Map
+//
+// Created by Benjamin Lacker on 4/20/12.
+// Copyright 2012 __MyCompanyName__. All rights reserved.
+//
+
+#import "MapViewAnnotation.h"
+
+@implementation MapViewAnnotation
+
+@synthesize title, coordinate;
+
+- (id)initWithTitle:(NSString *)ttl andCoordinate:(CLLocationCoordinate2D)c2d {
+ [super init];
+ title = ttl;
+ coordinate = c2d;
+ return self;
+}
+
+- (void)dealloc {
+ [title release];
+ [super dealloc];
+}
+
+@end
View
21 Sethoscope/MapViewController.h
@@ -0,0 +1,21 @@
+//
+// MapViewController.h
+// Map
+//
+// Created by Benjamin Lacker on 4/20/12.
+// Copyright 2012 __MyCompanyName__. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+#import <MapKit/MapKit.h>
+
+@interface MapViewController : UIViewController <MKMapViewDelegate> {
+
+ MKMapView *mapView;
+
+}
+
+@property (nonatomic, retain) IBOutlet MKMapView *mapView;
+
+@end
+
View
98 Sethoscope/MapViewController.m
@@ -0,0 +1,98 @@
+#import "MapViewController.h"
+#import "MapViewAnnotation.h"
+
+@implementation MapViewController
+
+@synthesize mapView;
+
+// When the view loads
+- (void)viewDidLoad
+{
+ // Set some coordinates for our position (Buckingham Palace!)
+ CLLocationCoordinate2D location;
+ MapViewAnnotation *newAnnotation;
+
+ // Add the annotation to our map view
+ location.latitude = (double) 37.545146;
+ location.longitude = (double) -77.4403859;
+ newAnnotation = [[MapViewAnnotation alloc] initWithTitle:@"Standard Drug" andCoordinate:location];
+ [self.mapView addAnnotation:newAnnotation];
+ [newAnnotation release];
+
+ // Add another annotation to our map view
+ location.latitude = (double) 37.5440306;
+ location.longitude = (double) -77.43947379;
+ newAnnotation = [[MapViewAnnotation alloc] initWithTitle:@"Central National Bank" andCoordinate:location];
+ [self.mapView addAnnotation:newAnnotation];
+ [newAnnotation release];
+
+ // Add another annotation to our map view
+ location.latitude = (double) 37.5437678;
+ location.longitude = (double) -77.43844360000003;
+ newAnnotation = [[MapViewAnnotation alloc] initWithTitle:@"Hot Nails" andCoordinate:location];
+ [self.mapView addAnnotation:newAnnotation];
+ [newAnnotation release];
+
+ // Add another annotation to our map view
+ location.latitude = (double) 37.541784;
+ location.longitude = (double) -77.437821699;
+ newAnnotation = [[MapViewAnnotation alloc] initWithTitle:@"Ardley" andCoordinate:location];
+ [self.mapView addAnnotation:newAnnotation];
+ [newAnnotation release];
+
+
+ [self.mapView setShowsUserLocation:YES];
+
+}
+
+// When a map annotation point is added, zoom to it (1500 range)
+- (void)mapView:(MKMapView *)mv didAddAnnotationViews:(NSArray *)views
+{
+
+ MKAnnotationView *annotationView = [views objectAtIndex:0];
+ id <MKAnnotation> mp = [annotationView annotation];
+ MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance([mp coordinate], 1500, 1500);
+ [mv setRegion:region animated:YES];
+ [mv selectAnnotation:mp animated:YES];
+}
+
+// hope this works
+- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
+ static NSString *identifier = @"MyLocation";
+ if ([annotation isKindOfClass:[MapViewAnnotation class]]) {
+
+ MKPinAnnotationView *annotationView = (MKPinAnnotationView *) [mapView dequeueReusableAnnotationViewWithIdentifier:identifier];
+ if (annotationView == nil) {
+ annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier];
+ } else {
+ annotationView.annotation = annotation;
+ }
+
+ annotationView.enabled = YES;
+ annotationView.canShowCallout = YES;
+
+ return annotationView;
+ }
+
+ return nil;
+}
+
+// Received memory warning
+- (void)didReceiveMemoryWarning {
+ [super didReceiveMemoryWarning];
+}
+
+// If the view unloads, release the map view
+- (void)viewDidUnload {
+ [super viewDidUnload];
+ [mapView release];
+ mapView = nil;
+}
+
+// Deallocations
+- (void)dealloc {
+ [mapView release];
+ [super dealloc];
+}
+
+@end
Please sign in to comment.
Something went wrong with that request. Please try again.