WWDC 2015

What's new in MapKit

Enhancement on API

Customization Pin color

pinTintColor for custom pin color

Callout customization

"popup" when tapping on pin

New detailCalloutAccessoryView for support auto-layout or stackview as complex layout inside of callout

  • it precedence to the subtitle if the detailCalloutAccessoryView is not nil

Map customization

mapView.showsTraffic to show traffic

mapView.showsScale to show scale

mapView.showsCompress to show compress

Timezone support

CLGeocoder
MKLocalSearch

Swift support

WatchKit Support

Traffic

MKDirectionsTransportType for selecting transport type

New transport type : Transit

ETA Request

//retrieving ETA to a POI
func getTransitETA(){
    let request = MKDirectionsRequest()
    /* Set Source */
    /* Set Destination */
    //Set Transport Type to be Transit
    request.transportType = MKDirectionsTransportType.Transit
    let directions = MKDirections(request: request)
    directions.calculateETAWithCompletionHandler { response, error in
        // Handle Response
    }
}
//opening native maps for getting transit guides
func openInMapsTransit(coord:CLLocationCoordinate2D) {
    var placemark = MKPlacemark(coordinate:coord, addressDictionary: nil)
    var mapItem = MKMapItem(placemark: placemark)
    let launchOptions = [MKLaunchOptionsDirectionsModeKey:MKLaunchOptionsDirectionsModeTransit]
    mapItem.openInMapsWithLaunchOptions(launchOptions)
}

Flyover

New Map Type: .SatelliteFlyover , .HybridFlyover

MKMapCamera Related session: WWDC 2013 Putting MapKit in Perspective

New camera init for flyover

init(lookingAtCenterCoordinate centerCoordinate: CLLocationCoordinate2D,
fromDistance distance:
CLLocationDistance,
pitch: CGFloat,
heading: CLLocationDirection)

MKOverlay

Use overlays to highlight areas of the map

  • Occluded by 3D buildings on Standard map type
  • Occluded by Flyover buildings and trees
  • Drawn on top of terrain (the layer still on the terrain as viewing in angle)