13. 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
14. Setting the Position
Set the region property
Defines the center point and a span
Span defines the vertical & horizontal distance to
display
30. Showing the User’s Location
Set the showsUserLocation property on the
MapView instance
Implement an Annotation
31. Showing the User’s Location
- (void)viewDidLoad
{
// Other initialisation…
mapView.showsUserLocation = YES;
}
32. 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…
}
NOT A COMPREHENSIVE PRESENTATION, just a brief introduction to what MK is, and some of the basic things which you can do with it.
What MapKit provides (if you didn&#x2019;t catch any of the 3.0 media).
What you need to do to support it in your iPhone application
Setting the position of the map
Adding & Managing Annotations
Using Core Location to be able to plot the user&#x2019;s current position on screen as well
Other hints & tips
NOT A COMPREHENSIVE PRESENTATION, just a brief introduction to what MK is, and some of the basic things which you can do with it.
What MapKit provides (if you didn&#x2019;t catch any of the 3.0 media).
What you need to do to support it in your iPhone application
Setting the position of the map
Adding & Managing Annotations
Using Core Location to be able to plot the user&#x2019;s current position on screen as well
Other hints & tips
NOT A COMPREHENSIVE PRESENTATION, just a brief introduction to what MK is, and some of the basic things which you can do with it.
What MapKit provides (if you didn&#x2019;t catch any of the 3.0 media).
What you need to do to support it in your iPhone application
Setting the position of the map
Adding & Managing Annotations
Using Core Location to be able to plot the user&#x2019;s current position on screen as well
Other hints & tips
NOT A COMPREHENSIVE PRESENTATION, just a brief introduction to what MK is, and some of the basic things which you can do with it.
What MapKit provides (if you didn&#x2019;t catch any of the 3.0 media).
What you need to do to support it in your iPhone application
Setting the position of the map
Adding & Managing Annotations
Using Core Location to be able to plot the user&#x2019;s current position on screen as well
Other hints & tips
NOT A COMPREHENSIVE PRESENTATION, just a brief introduction to what MK is, and some of the basic things which you can do with it.
What MapKit provides (if you didn&#x2019;t catch any of the 3.0 media).
What you need to do to support it in your iPhone application
Setting the position of the map
Adding & Managing Annotations
Using Core Location to be able to plot the user&#x2019;s current position on screen as well
Other hints & tips
NOT A COMPREHENSIVE PRESENTATION, just a brief introduction to what MK is, and some of the basic things which you can do with it.
What MapKit provides (if you didn&#x2019;t catch any of the 3.0 media).
What you need to do to support it in your iPhone application
Setting the position of the map
Adding & Managing Annotations
Using Core Location to be able to plot the user&#x2019;s current position on screen as well
Other hints & tips
Added in 3.0
Embed Google Maps in your app
Full UX of Maps application (panning, scrolling, Views etc).
Supports regular, satellite, hybrid maps
Handles caching, tile loading, memory warnings, connectivity changes
This is a general screenshot from my App.
Shows mapview with a single annotation & callout
Will explain full process later
Why CL? MK uses some of the CL types.
Also may want to integrate CL into your app (eg. showing user&#x2019;s location on a map)
- Region takes an MKCoordinateRegion struct
- Centre is the latitude & longitude point which define the location which is centred on screen.
- Span defines the zoom level via the lat/long range (in degrees).
- Check MKCoordinateSpan in the docs for how it needs to be set
(long varies depending on the latitude).
- Setting this will have an impact on the zoom level due to all of that
- Can adjust the centre position without impacting zoom by setting the centerCoordinate property (takes a CLLocationCoordinate2D type)
- Snippet from my App
- 1-2 init MKMapView (via code)
- 4-8 set the centre to the location (user value), plus the zoom level. (0.5km lat)
- 10 sets the region to our generated one
- Can have any number of annotations on your map
- Coordinate is required (as you need to have a location).
- Title & Subtitle are optional (although title is recommended).
- T & ST are used as the primary & secondary labels on the default callout