ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
Intro to the MapKit
     Code Review: 3/30/12
The Plan
?   What is MapKit?

?   Adding MapKit to your iPhone Application

?   Setting the Position

?   Annotations

?   Geocoding

?   Interacting with Core Location
What is MapKit?
?   Embed Maps in your App

?   Based on Google Maps
Adding MapKit to your App
?   Add the Mapkit & CoreLocation frameworks

?   Create a View Controller which implements MKMapViewDelegate

?   Create an MKMapView instance and connect to the controller
Setting the Position
?   Set the region property

?   Define the center point and a span

?   Span defines the vertical & horizontal distance to display (zoom)
                  - (void)viewDidLoad?{? MKCoordinateRegion region;? region.center.latitude = [eventVenue.latitude doubleValue
                  }
Annotations
?   Allow you to add places-of-interest to a Map

?   Implemented with a Model & a View

?   Only limited by amount of free memory on the device
Annotation Models
?   Implement the MKAnnotation protocol

?   Exposes a Title, Subtitle, and Coordinate



                            Title

                           Subtitle

                             Coordinate
Annotation Views
?   Use MKAnnotationView

?   Easiest trick to set the image property

?   Use MKPinAnnotationView if you want the Pin

?   If you don¡¯t need a specific image, it¡¯s best to just use the Pin.

?   NB: Pin has 3 different colors: Red (which is the default for indicating a
    location), Green (for indicating the start point), and Purple (which is user
    defined).
Managing Annotation Views
- (MKAnnotationView *)mapView:(MKMapView *)theMapView
        viewForAnnotation:(id <MKAnnotation>)annotation?{? MKPinAnnotationView *annotationView =
   (MKPinAnnotationView *)([theMapView
    dequeueReusableAnnotationViewWithIdentifier:@"annotation"]);? ? if (annotationView == NULL)? {? annotationView
= [[[MKPinAnnotationView alloc]
    initWithAnnotation:annotation reuseIdentifier:@"annotation"] autorelease];? annotationView.canShowCallout = YES;?
annotationView.animatesDrop = YES;? }?? annotationView.annotation = annotation;? return annotationView;?}
Geocoding
?   Convert Landmarks into Longitude/Latitude?and vice-versa

?   SDK 3.0+ Supports Reverse Geocoding only

?   For forward geocoding, you can use services like Google or Yahoo
Reverse Geocoding
?   Use MKReverseGeocoder

?   Requires network access (Wifi/3G/EDGE)

?   Asynchronous lookups
Interacting with Core Location
?   Set the showsUserLocation property on the MapView instance

?   Implement an Annotation

?   Setting showsUserLocation to YES enables it (so you¡¯ll get CL authorization
    pop-ups)
                 - (void)viewDidLoad?{
                   // Other initialisation¡­

                     mapView.showsUserLocation = YES;
                 }
Showing the User¡¯s Location
- (MKAnnotationView *)mapView:(MKMapView *)theMapView
       viewForAnnotation:(id <MKAnnotation>)annotation?{? // Checks to see if we
are going to add the annotation for the users's location.? // If this is the case, then we
don't bother with creating an annotation and let? // the platform give us the blue
dot.? if (annotation == mapView.userLocation) return nil;?
  // Configuring other annotations¡­?}

More Related Content

What's hot (16)

Easily Create Maps in Drupal with Leaflet
Easily Create Maps in Drupal with LeafletEasily Create Maps in Drupal with Leaflet
Easily Create Maps in Drupal with Leaflet
Amber Matz
?
UI optimization for night
UI optimization for nightUI optimization for night
UI optimization for night
Keishin Yokomaku
?
mago3D: Let's integrate BIM and 3D GIS on top of FOSS4G
mago3D: Let's integrate BIM and 3D GIS on top of FOSS4Gmago3D: Let's integrate BIM and 3D GIS on top of FOSS4G
mago3D: Let's integrate BIM and 3D GIS on top of FOSS4G
SANGHEE SHIN
?
Terra formation control or how to move mountains
Terra formation control or how to move mountainsTerra formation control or how to move mountains
Terra formation control or how to move mountains
ijcga
?
Web Mapping with Drupal
Web Mapping with DrupalWeb Mapping with Drupal
Web Mapping with Drupal
Ranel Padon
?
Google Earth
Google EarthGoogle Earth
Google Earth
bananagrl6913
?
Google Earth
Google EarthGoogle Earth
Google Earth
chrissy3130
?
Google Maps JS API
Google Maps JS APIGoogle Maps JS API
Google Maps JS API
Alberto Sim?es
?
Global mapper
Global mapperGlobal mapper
Global mapper
upn
?
Map Feature Extraction from Satellite Imagery
Map Feature Extraction from Satellite ImageryMap Feature Extraction from Satellite Imagery
Map Feature Extraction from Satellite Imagery
Igor Berman
?
Google earth
Google earthGoogle earth
Google earth
kondalarao7
?
Google Earth Presentation
Google Earth PresentationGoogle Earth Presentation
Google Earth Presentation
abc
?
Android location
Android locationAndroid location
Android location
Krazy Koder
?
ICU MULTIVIEW
ICU MULTIVIEWICU MULTIVIEW
ICU MULTIVIEW
G2 Research Ltd.
?
Map reduce presentation
Map reduce presentationMap reduce presentation
Map reduce presentation
rajab ssemwogerere
?
High-Quality Server Side Rendering using the OGC¡¯s 3D Portrayal Service ¨C App...
High-Quality Server Side Rendering using the OGC¡¯s 3D Portrayal Service ¨C App...High-Quality Server Side Rendering using the OGC¡¯s 3D Portrayal Service ¨C App...
High-Quality Server Side Rendering using the OGC¡¯s 3D Portrayal Service ¨C App...
Martin Christen
?
Easily Create Maps in Drupal with Leaflet
Easily Create Maps in Drupal with LeafletEasily Create Maps in Drupal with Leaflet
Easily Create Maps in Drupal with Leaflet
Amber Matz
?
mago3D: Let's integrate BIM and 3D GIS on top of FOSS4G
mago3D: Let's integrate BIM and 3D GIS on top of FOSS4Gmago3D: Let's integrate BIM and 3D GIS on top of FOSS4G
mago3D: Let's integrate BIM and 3D GIS on top of FOSS4G
SANGHEE SHIN
?
Terra formation control or how to move mountains
Terra formation control or how to move mountainsTerra formation control or how to move mountains
Terra formation control or how to move mountains
ijcga
?
Web Mapping with Drupal
Web Mapping with DrupalWeb Mapping with Drupal
Web Mapping with Drupal
Ranel Padon
?
Global mapper
Global mapperGlobal mapper
Global mapper
upn
?
Map Feature Extraction from Satellite Imagery
Map Feature Extraction from Satellite ImageryMap Feature Extraction from Satellite Imagery
Map Feature Extraction from Satellite Imagery
Igor Berman
?
Google Earth Presentation
Google Earth PresentationGoogle Earth Presentation
Google Earth Presentation
abc
?
High-Quality Server Side Rendering using the OGC¡¯s 3D Portrayal Service ¨C App...
High-Quality Server Side Rendering using the OGC¡¯s 3D Portrayal Service ¨C App...High-Quality Server Side Rendering using the OGC¡¯s 3D Portrayal Service ¨C App...
High-Quality Server Side Rendering using the OGC¡¯s 3D Portrayal Service ¨C App...
Martin Christen
?

Viewers also liked (9)

Design pattern proxy½é½B 20130805
Design pattern proxy½é½B 20130805Design pattern proxy½é½B 20130805
Design pattern proxy½é½B 20130805
LearningTech
?
Proxy pattern
Proxy patternProxy pattern
Proxy pattern
Shakil Ahmed
?
Proxy pattern
Proxy patternProxy pattern
Proxy pattern
Chester Hartin
?
Proxy Design Patterns
Proxy Design PatternsProxy Design Patterns
Proxy Design Patterns
Zafer Genc
?
Proxy design pattern (Class Ambassador)
Proxy design pattern (Class Ambassador)Proxy design pattern (Class Ambassador)
Proxy design pattern (Class Ambassador)
Sameer Rathoud
?
Proxy Design Pattern
Proxy Design PatternProxy Design Pattern
Proxy Design Pattern
Anjan Kumar Bollam
?
Proxy design pattern
Proxy design patternProxy design pattern
Proxy design pattern
Sase Kleckovski
?
Proxy Pattern
Proxy PatternProxy Pattern
Proxy Pattern
H¨¹seyin Ergin
?
Design Patterns Presentation - Chetan Gole
Design Patterns Presentation -  Chetan GoleDesign Patterns Presentation -  Chetan Gole
Design Patterns Presentation - Chetan Gole
Chetan Gole
?
Design pattern proxy½é½B 20130805
Design pattern proxy½é½B 20130805Design pattern proxy½é½B 20130805
Design pattern proxy½é½B 20130805
LearningTech
?
Proxy Design Patterns
Proxy Design PatternsProxy Design Patterns
Proxy Design Patterns
Zafer Genc
?
Proxy design pattern (Class Ambassador)
Proxy design pattern (Class Ambassador)Proxy design pattern (Class Ambassador)
Proxy design pattern (Class Ambassador)
Sameer Rathoud
?
Design Patterns Presentation - Chetan Gole
Design Patterns Presentation -  Chetan GoleDesign Patterns Presentation -  Chetan Gole
Design Patterns Presentation - Chetan Gole
Chetan Gole
?

Similar to Map kit (20)

Core Location and Map Kit: Bringing Your Own Maps [Voices That Matter: iPhone...
Core Location and Map Kit: Bringing Your Own Maps [Voices That Matter: iPhone...Core Location and Map Kit: Bringing Your Own Maps [Voices That Matter: iPhone...
Core Location and Map Kit: Bringing Your Own Maps [Voices That Matter: iPhone...
Chris Adamson
?
Keeping Track of Moving Things: MapKit and CoreLocation in Depth
Keeping Track of Moving Things: MapKit and CoreLocation in DepthKeeping Track of Moving Things: MapKit and CoreLocation in Depth
Keeping Track of Moving Things: MapKit and CoreLocation in Depth
Geoffrey Goetz
?
WhereCamp EU talk: iPhone location 101
WhereCamp EU talk: iPhone location 101WhereCamp EU talk: iPhone location 101
WhereCamp EU talk: iPhone location 101
Michael Dales
?
Boldly Go Where No Man Has Gone Before. Explore Geo on iPhone & Android
Boldly Go Where No Man Has Gone Before. Explore Geo on iPhone & AndroidBoldly Go Where No Man Has Gone Before. Explore Geo on iPhone & Android
Boldly Go Where No Man Has Gone Before. Explore Geo on iPhone & Android
Bess Ho
?
Swift Map
Swift MapSwift Map
Swift Map
Futada Takashi
?
Introduction to the geolocation & Apple's maps API
Introduction to the geolocation & Apple's maps APIIntroduction to the geolocation & Apple's maps API
Introduction to the geolocation & Apple's maps API
Julian Kr¨®l
?
Getting Oriented with MapKit
Getting Oriented with MapKitGetting Oriented with MapKit
Getting Oriented with MapKit
Juio Barros
?
DIY Uber
DIY UberDIY Uber
DIY Uber
NSCoder Mexico
?
Mapping on iOS and Android, Wally McClure
Mapping on iOS and Android, Wally McClureMapping on iOS and Android, Wally McClure
Mapping on iOS and Android, Wally McClure
Xamarin
?
Finding Your Way Around Map Kit
Finding Your Way Around Map KitFinding Your Way Around Map Kit
Finding Your Way Around Map Kit
mobiledatasolutions
?
IOS 8 Indoor Location
IOS 8 Indoor LocationIOS 8 Indoor Location
IOS 8 Indoor Location
Ludovic Privat
?
Core Location in iOS
Core Location in iOSCore Location in iOS
Core Location in iOS
Juan C Catalan
?
iOS Core location
iOS Core locationiOS Core location
iOS Core location
Richa Jain
?
Google Map Implementation with offline feature.
Google Map Implementation with offline feature.Google Map Implementation with offline feature.
Google Map Implementation with offline feature.
Jayanta Sinhamahapatra
?
Zenly - Reverse geocoding
Zenly - Reverse geocodingZenly - Reverse geocoding
Zenly - Reverse geocoding
CocoaHeads France
?
Curso IOS - Intro
Curso IOS - IntroCurso IOS - Intro
Curso IOS - Intro
Platzi
?
Continuaci¨®n Intro iOS
Continuaci¨®n Intro iOSContinuaci¨®n Intro iOS
Continuaci¨®n Intro iOS
brainybogota
?
I os developers_meetup_4_sessionon_locationservices
I os developers_meetup_4_sessionon_locationservicesI os developers_meetup_4_sessionon_locationservices
I os developers_meetup_4_sessionon_locationservices
Mahboob Nur
?
203 Is It Real or Is It Virtual? Augmented Reality on the iPhone
203 Is It Real or Is It Virtual? Augmented Reality on the iPhone203 Is It Real or Is It Virtual? Augmented Reality on the iPhone
203 Is It Real or Is It Virtual? Augmented Reality on the iPhone
jonmarimba
?
Geolocation and Mapping
Geolocation and MappingGeolocation and Mapping
Geolocation and Mapping
Ivano Malavolta
?
Core Location and Map Kit: Bringing Your Own Maps [Voices That Matter: iPhone...
Core Location and Map Kit: Bringing Your Own Maps [Voices That Matter: iPhone...Core Location and Map Kit: Bringing Your Own Maps [Voices That Matter: iPhone...
Core Location and Map Kit: Bringing Your Own Maps [Voices That Matter: iPhone...
Chris Adamson
?
Keeping Track of Moving Things: MapKit and CoreLocation in Depth
Keeping Track of Moving Things: MapKit and CoreLocation in DepthKeeping Track of Moving Things: MapKit and CoreLocation in Depth
Keeping Track of Moving Things: MapKit and CoreLocation in Depth
Geoffrey Goetz
?
WhereCamp EU talk: iPhone location 101
WhereCamp EU talk: iPhone location 101WhereCamp EU talk: iPhone location 101
WhereCamp EU talk: iPhone location 101
Michael Dales
?
Boldly Go Where No Man Has Gone Before. Explore Geo on iPhone & Android
Boldly Go Where No Man Has Gone Before. Explore Geo on iPhone & AndroidBoldly Go Where No Man Has Gone Before. Explore Geo on iPhone & Android
Boldly Go Where No Man Has Gone Before. Explore Geo on iPhone & Android
Bess Ho
?
Introduction to the geolocation & Apple's maps API
Introduction to the geolocation & Apple's maps APIIntroduction to the geolocation & Apple's maps API
Introduction to the geolocation & Apple's maps API
Julian Kr¨®l
?
Getting Oriented with MapKit
Getting Oriented with MapKitGetting Oriented with MapKit
Getting Oriented with MapKit
Juio Barros
?
Mapping on iOS and Android, Wally McClure
Mapping on iOS and Android, Wally McClureMapping on iOS and Android, Wally McClure
Mapping on iOS and Android, Wally McClure
Xamarin
?
iOS Core location
iOS Core locationiOS Core location
iOS Core location
Richa Jain
?
Google Map Implementation with offline feature.
Google Map Implementation with offline feature.Google Map Implementation with offline feature.
Google Map Implementation with offline feature.
Jayanta Sinhamahapatra
?
Curso IOS - Intro
Curso IOS - IntroCurso IOS - Intro
Curso IOS - Intro
Platzi
?
Continuaci¨®n Intro iOS
Continuaci¨®n Intro iOSContinuaci¨®n Intro iOS
Continuaci¨®n Intro iOS
brainybogota
?
I os developers_meetup_4_sessionon_locationservices
I os developers_meetup_4_sessionon_locationservicesI os developers_meetup_4_sessionon_locationservices
I os developers_meetup_4_sessionon_locationservices
Mahboob Nur
?
203 Is It Real or Is It Virtual? Augmented Reality on the iPhone
203 Is It Real or Is It Virtual? Augmented Reality on the iPhone203 Is It Real or Is It Virtual? Augmented Reality on the iPhone
203 Is It Real or Is It Virtual? Augmented Reality on the iPhone
jonmarimba
?

More from Chester Hartin (7)

Xamarin 101
Xamarin 101Xamarin 101
Xamarin 101
Chester Hartin
?
Asynchronous programming
Asynchronous programmingAsynchronous programming
Asynchronous programming
Chester Hartin
?
Elapsed time
Elapsed timeElapsed time
Elapsed time
Chester Hartin
?
Dependency injection
Dependency injectionDependency injection
Dependency injection
Chester Hartin
?
Hash tables
Hash tablesHash tables
Hash tables
Chester Hartin
?
Parallel extensions
Parallel extensionsParallel extensions
Parallel extensions
Chester Hartin
?
Reflection
ReflectionReflection
Reflection
Chester Hartin
?

Map kit

  • 1. Intro to the MapKit Code Review: 3/30/12
  • 2. The Plan ? What is MapKit? ? Adding MapKit to your iPhone Application ? Setting the Position ? Annotations ? Geocoding ? Interacting with Core Location
  • 3. What is MapKit? ? Embed Maps in your App ? Based on Google Maps
  • 4. Adding MapKit to your App ? Add the Mapkit & CoreLocation frameworks ? Create a View Controller which implements MKMapViewDelegate ? Create an MKMapView instance and connect to the controller
  • 5. Setting the Position ? Set the region property ? Define the center point and a span ? Span defines the vertical & horizontal distance to display (zoom) - (void)viewDidLoad?{? MKCoordinateRegion region;? region.center.latitude = [eventVenue.latitude doubleValue }
  • 6. Annotations ? Allow you to add places-of-interest to a Map ? Implemented with a Model & a View ? Only limited by amount of free memory on the device
  • 7. Annotation Models ? Implement the MKAnnotation protocol ? Exposes a Title, Subtitle, and Coordinate Title Subtitle Coordinate
  • 8. Annotation Views ? Use MKAnnotationView ? Easiest trick to set the image property ? Use MKPinAnnotationView if you want the Pin ? If you don¡¯t need a specific image, it¡¯s best to just use the Pin. ? NB: Pin has 3 different colors: Red (which is the default for indicating a location), Green (for indicating the start point), and Purple (which is user defined).
  • 9. Managing Annotation Views - (MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id <MKAnnotation>)annotation?{? MKPinAnnotationView *annotationView = (MKPinAnnotationView *)([theMapView dequeueReusableAnnotationViewWithIdentifier:@"annotation"]);? ? if (annotationView == NULL)? {? annotationView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"annotation"] autorelease];? annotationView.canShowCallout = YES;? annotationView.animatesDrop = YES;? }?? annotationView.annotation = annotation;? return annotationView;?}
  • 10. Geocoding ? Convert Landmarks into Longitude/Latitude?and vice-versa ? SDK 3.0+ Supports Reverse Geocoding only ? For forward geocoding, you can use services like Google or Yahoo
  • 11. Reverse Geocoding ? Use MKReverseGeocoder ? Requires network access (Wifi/3G/EDGE) ? Asynchronous lookups
  • 12. Interacting with Core Location ? Set the showsUserLocation property on the MapView instance ? Implement an Annotation ? Setting showsUserLocation to YES enables it (so you¡¯ll get CL authorization pop-ups) - (void)viewDidLoad?{ // Other initialisation¡­ mapView.showsUserLocation = YES; }
  • 13. Showing the User¡¯s Location - (MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id <MKAnnotation>)annotation?{? // Checks to see if we are going to add the annotation for the users's location.? // If this is the case, then we don't bother with creating an annotation and let? // the platform give us the blue dot.? if (annotation == mapView.userLocation) return nil;? // Configuring other annotations¡­?}