Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Geolocalizacin
Introduccin
Muchas aplicaciones usan geolocalizacin En iPhone OS - Core Location Framework - MapKit Framework Hay que tener cuidad con el consumo de batera Triangulacin celular < Wifi < GPS
Localizacin y precisin
CLLocation Objeto representa un punto y vector CLLocationManagerDelegate (Protocolo) didUpdateToLocation:fromLocation DidUpdateHeading didFailLoadWithError
CLLocation
Estructura
CLLocationCoordinate2D coordinate; CLLocationDistance altitude; CLLocationAccuracy horizontalAccuracy; CLLocationAccuracy verticalAccuracy; CLLocationDirection course; CLLocationSpeed speed; -(NSDAte*)timestamp; -distanceFromLocation:(CLLocation*)location
CLLocationManager
Estructura
CLLocation *location; Id <CLLocationManagerDelegate> delegate; CLLocationDistance distanceFilter; CLLocationAccuracy desiredAccuracy; -(void)startUpdatingLocation -(void)stopUpdatingLocation -(void)startUpdatingHeading -(void)stopUpdatingHeading
CLLocationManagerDelegate
Mtodo cuando cambia la localizacin - didUpdateToLocation:fromLocation; Mtodo cuando cambia la orientacin - didUpdateHeading; Mtodo para manejar los errores - didFailWithError;
MapKit Framework
API para mostrar mapas Clases para traducir coordenadas en direcciones (reversegeocoding) Soporta anotaciones sobre el mapa
MapKit Framework
Clases: MKMapView MKAnnotationView MKPlaceMark MKUserLocation MKReverseGeocoder Protocolos MKAnnotation Protocol MKMapViewDelegate
MKReverseGeocoderDelegate
MKMapView
Es la vista que se encarga de mostrar el mapa y las anotaciones Configuracin inicial del mapa Regin visible del mapa (punto central + span) Span: Cunto se ve del mapa Anotaciones de la vista Objeto que cumple protocolo MKAnnotation Mapa tiene NSArray objetos anotacin
MKMapView
Es la vista que se encarga de mostrar el mapa y las anotaciones Configuracin inicial del mapa Regin visible del mapa (punto central + span) Span: Cunto se ve del mapa Anotaciones de la vista Objeto que cumple protocolo MKAnnotation Mapa tiene NSArray objetos anotacin
MKMapView
Propiedades MKCoordinateRegion region; CLLocationCoordinate2D centerCoordinate; MKMapType mapType; NSArray *annotations; MKUserLocation userLocation; id <MKMapViewDelegate> delegate;
MKMapViewDelegate
mapViewDidFinishLoadingMap
mapViewDidFailLoadingMap:withError Mtodos sobre cambio de regin: regionWillChangeAnimated regionDidChangeAnimated Mtodos para anotaciones: viewForAnnotation didAddAnnotationViews annotationView:calloutAccessoryControlTapped
MKAnnotation
Es un protocolo, NO una clase El objeto que quiera cumplir el protocolo: @property CLLocationCoordinate2D coordinate; @property NSString *title; @property NSString *subtitle;
MKUserLocation
Caso especial de MKAnnotation Representa la localizacin del dispositivo Estructura: - @property BOOL updating (getter = isUpdating); - @property CLLocation *location; - @property NSString *title; - @property NSString *subtitle;
MKAnnotationView
- Vista para cada anotacin MKPinAnnotationView - Reusable (como UITableViewCell) - Callouts o 'bocadillos'
MKPlacemark
- Cumple protocolo MKAnnotation - Clase para almacenar una relacin entre coordenadas y direcciones legibles - initWithCoordinate:addressDictionary - Estructura Objetos NSString para almacenar calle, localidad, pas...
MKReverseGeocoder
Usa un servicio de red para convertir entre coordenadas y direccin legible (Google) Necesita conexin a internet Devuelve objeto MKPlacemark Protocolo MKReverseGeocoderDelegate - didFindPlacemark:(MKPlacemark *)placemark
Bibliografa
Core Location Framework Reference MapKit Framework Reference Location Awareness Programming Guide http://developer.apple.com