Wednesday, September 9, 2015

MKMapView and MKMapCamera Few notes


MKMapView provides embedded map interface. When initializing Mapview, we should provide a regionn. A region is defined by a center and a horizontal and vertical distance referred to as span. The span defines how much of the map at a given point should be visible and is also how you set the zoom level. Specifying a small span results in the user seeing a more narrow geographical area and corresponds to a higher zoom level. 

An annotation object is any object that conforms to MKAnnotation protocol. The presentation of annotation objects on the map is using MKAnnotationView. Because annotation view are needed only when they are on the screen. Annotation views with a reuse identifier can be detached and queued internally by the map view when they move offscreen. This feature improves memory use by keeping only a small number of annotation views in memory at once and by recycling recycling the views you do have. 

For adding overlays to the Map, we need to have overlay object which conforms to the MKOverLay protocol. An overlay object is a data object that contains the points needed to specify the shape and size of the overlay and its location on the map. Overlays can represents shapes such as Circles, rectangles, multi-segment lines and simple or complex polygons. Developer can also define custom overlays. the presentation of Overlay is done by the MKOverlayRenderer class. 

When configuring the map, the overlay objects can be added at any time. The map view uses data in each overlay object to determine when corresponding overlay view needs to appear on screen. When an overlay moves on screen, the map view asks its delegate to create a corresponding overlay renderer. 

MKMapCamera object describes a virtual camera that we can use to define the appearance of the map. A camera object creates a virtual viewpoint above the map surface and affects how the map renders its tiles and other content. We can use camera object to specify the location of the camera on the map, the compass heading that corresponds to camera’s viewing direction, the pitch of the camera relative to the map perpendicular and camera’s altitude above the map. These factors let the map to appear like 3D. 

Map can be centered with the MKMapCamera’s centerCoordinate property. 

References:

No comments:

Post a Comment