WWDC 19
What’s New in MapKit and MapKit JS
Maps Web Snapshots:
Snapshot service for generating static images of a map fragment (similar API has already existed in native MapKit since iOS 7 – MKMapSnapshotter
)
URL like: http://snapshot.apple-mapkit.com/api/v1/snapshot?center=50.0,20.0&size=800×600 (requires API key)
20K free snapshots per day on the free plan
Maps automatically support dark mode on iOS and the web
For map snapshots, set traitCollection
in options manually to get a dark snapshot and update the snapshot if needed when appearance changes
Showing/hiding specific categories of places on the map:
MKPointOfInterestFilter
, MKPointOfInterestCategory
MKPointOfInterestFilter(excluding:)
or MKPointOfInterestFilter(including:)
, or .excludingAll
Filtering search:
MKLocalSearchCompleter.pointOfInterestFilter
, MKLocalSearch.Request.pointOfInterestFilter
Removing addresses from search results:
MKLocalSearchCompleter.filterType
⭢ .resultTypes
(.address
/ .pointOfInterest
/ .query
)
MKLocalSearch.Request.resultTypes
(.address
/ .pointOfInterest
)
Results: MKMapItem.pointOfInterestCategory
(You might get results with a different pointOfInterestCategory
than the filter you’ve set, because some places may have a primary and secondary category)
MKMultiPolygon
, MKMultiLine
– for creating groups of map overlays with the same settings (colors etc.)
MKMultiPolygonRenderer
, MKMultiLineRenderer
(whole group uses one renderer)
Overlays are now rendered as vectors, not bitmaps
Opt out with: MKOverlayPathRenderer.shouldRasterize = true
Parsing GeoJSON: MKGeoJSONFeature
, MKGeoJSONDecoder
Indoor Mapping Data Format – built on top of GeoJSON
Camera boundary: puts a constraint on how far the user can move/zoom out, by specifying a region in which the map center must be contained
mapView.cameraBoundary
/ MKMapView.CameraBoundary
Specify using MKMapRect
or MKCoordinateRegion
This is also enforced when moving the map programatically
centerCoordinateDistance
mapView.cameraZoomRange = MKMapView.CameraZoomRange(…)