DOC PREVIEW
SDSU CS 696 - MapKit

This preview shows page 1-2-3-24-25-26 out of 26 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CS 696 Mobile Phone Application DevelopmentFall Semester, 2010Doc 18 MapKitNov 2, 2010Copyright ©, All rights reserved. 2010 SDSU & Roger Whitney, 5500 Campanile Drive, San Diego, CA 92182-7700 USA. OpenContent (http://www.opencontent.org/opl.shtml) license defines the copyright on this document.References2Location Awareness Programming Guide, Apple Documentation, http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/LocationAwarenessPG/Introduction/Introduction.htmlMore iPhone 3 Development: Tacking iPhone SDK 3, Mark, LaMarche, Apress, 2009, Chapter 11Maps3MKMapViewMKMapViewDelegateMKReverseGeocoderDelegateCLLocationManagerDelegateClassesFrameworksCoreLocationMapKitGoogle Maps4http://code.google.com/apis/maps/iphone/terms.htmlMapkit uses Google mapsLicense AgreementLocation & Geocoding5Latitude & Longitude<+32.76572793, -117.07319879>Address5500 Campanile DriveSan Diego, CA 92182ReverseGeocodingGeocodingCoreLocation only supports reverse geocodingCoreLocation6CLLocationCLLocationManagerCLHeadingUsesGPSWifiCell Network More accurate the more powerkCLLocationAccuracyBest;kCLLocationAccuracyNearestTenMeters;kCLLocationAccuracyHundredMeters;kCLLocationAccuracyKilometer;kCLLocationAccuracyThreeKilometers;CLLocation7@property CLLocationCoordinate2D coordinate; @property CLLocationDistance altitude;@property CLLocationAccuracy horizontalAccuracy; @property CLLocationAccuracy verticalAccuracy;@property CLLocationDirection course; @property CLLocationSpeed speed;- (NSDate *)timeStamp; - (CLLocationDistance)distanceFromLocation:(CLLocation *)locationlocation: <+32.76572793, -117.07319879> +/- 100.00m (speed -1.00 mps / course -1.00) @ 2010-11-02 01:56:29 GMTPoint in real world plus direction and speedCLLocationManager8Starting point for Location@property CLLocation *location; @property id <CLLocationManagerDelegate> delegate;@property CLLocationDistance distanceFilter; @property CLLocationAccuracy verticalAccuracy;- (void)startUpdatingLocation - (void)stopUpdatingLocation - (void)startUpdatingHeading - (void)stopUpdatingHeading- (void)startMonitoringForRegion:(CLRegion *)region desiredAccuracy:(CLLocationAccuracy)accuracyCLLocationManagerDelegate9Callbacks for Location Change – locationManager:didUpdateToLocation:fromLocation: – locationManager:didFailWithError: – locationManager:didUpdateHeading: – locationManagerShouldDisplayHeadingCalibration: – locationManager:didEnterRegion: – locationManager:didExitRegion: – locationManager:monitoringDidFailForRegion:withError:Callbacks for Heading ChangeCallbacks for Region EventsMapKit10Displays Google MapsReverse GeocodingPins on maps (annotations)MKMapViewMKMapViewDelegateMKAnnotationMKPlacemarkMKUserLocationMKReverseGeocoderMKMapView11Displays mapMap & SatellitePanning & zoomingAnnotationsUser locationMKMapViewDelegate12Responding to Map Position Changes – mapView:regionWillChangeAnimated: – mapView:regionDidChangeAnimated:Loading the Map Data – mapViewWillStartLoadingMap: – mapViewDidFinishLoadingMap: – mapViewDidFailLoadingMap:withError:Tracking the User Location – mapViewWillStartLocatingUser: – mapViewDidStopLocatingUser: – mapView:didUpdateUserLocation: – mapView:didFailToLocateUserWithError:Managing Annotation Views – mapView:viewForAnnotation: – mapView:didAddAnnotationViews: – mapView:annotationView:calloutAccessoryControlTapped:Dragging an Annotation View – mapView:annotationView:didChangeDragState:fromOldState:Selecting Annotation Views – mapView:didSelectAnnotationView: – mapView:didDeselectAnnotationView:Managing Overlay Views – mapView:viewForOverlay: – mapView:didAddOverlayViews:TextMKAnnotation13Add to map view to show pinsOnly a protocolNeed to create class that implements protocol@property CLLocationCoordinate2D coordinate;@property NSString *title; @property NSString *subtitle;MKReverseGeocoder14Reverse geocodes latitude/longitude to addressNeeds delegate to get resultExample15Need to add Frameworks:MapKitCoreLocationMapViewController16#import <UIKit/UIKit.h>#import <MapKit/MapKit.h>#import <CoreLocation/CoreLocation.h>@interface MapViewController : UIViewController <CLLocationManagerDelegate, MKReverseGeocoderDelegate, MKMapViewDelegate>{}@property (nonatomic, retain) IBOutlet MKMapView *mapView;- (IBAction)findMe;- (IBAction)showThere;@endShowing the World17- (void)viewDidLoad { [super viewDidLoad]; mapView.mapType = MKMapTypeStandard; mapView.showsUserLocation = YES;}Restricting the Map18- (void)viewDidLoad { [super viewDidLoad]; CLLocationCoordinate2D sanDiego = {latitude: 32.76572795, longitude: -117.07319880}; MKCoordinateSpan span = {latitudeDelta: 0.9, longitudeDelta: 0.5}; MKCoordinateRegion county = {sanDiego, span}; mapView.region = county; mapView.mapType = MKMapTypeStandard; mapView.showsUserLocation = YES;}Adding an annotation19- (IBAction)showThere { AnnotatedLocation *annotation = [[AnnotatedLocation alloc] init]; CLLocationCoordinate2D there = {latitude: 32.955, longitude: -117.2459}; annotation.coordinate = there; [annotation setTitle: @"There"]; annotation.subtitle = @"You are not here"; [mapView addAnnotation:annotation]; [annotation release]; }AnnotatedLocation20#import <Foundation/Foundation.h>#import <MapKit/MapKit.h>@interface AnnotatedLocation : NSObject <MKAnnotation>{ NSString * title;}@property (nonatomic, readwrite) CLLocationCoordinate2D coordinate;@property (nonatomic, readwrite, retain) NSString *subtitle;- (void)setTitle: (NSString *) aTitle; @property (nonatomic, copy) NSString *streetAddress;@property (nonatomic, copy) NSString *city;@property (nonatomic, copy) NSString *state;@property (nonatomic, copy) NSString *zip;@endAnnotatedLocation21@implementation AnnotatedLocation@synthesize coordinate;@synthesize subtitle;@synthesize streetAddress;@synthesize city;@synthesize state;@synthesize zip;- (NSString *)title { return title; }- (void)setTitle: (NSString *) aTitle { title = [aTitle copy];}@endUsing Location Manager22- (IBAction)findMe { NSLog(@"FindMe"); CLLocationManager *finder = [[CLLocationManager alloc] init]; finder.delegate = self; finder.desiredAccuracy = kCLLocationAccuracyBest; [finder startUpdatingLocation]; }Location Manager Delegate Methods23- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error { NSString *errorType = (error.code ==


View Full Document

SDSU CS 696 - MapKit

Download MapKit
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view MapKit and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view MapKit 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?