Como usar el GPS en vuestras aplicaciones

Share


Imagino que muchos de vosotros ya conocéis el funcionamiento del GPS gracias al framework de CoreLocation, pero para otros muchos que se incorporan al mundillo del desarrollo de aplicaciones para iPhone, vamos a explicarlo.

En primer lugar, es necesario, q en nuestro proyecto incluyamos el framework CoreLocation que anteriormente hemos comentado, y para ello os recuerdo el artículo donde ya explicamos como hacerlo.

El funcionamiento de la detección del punto donde nos encontramos, gracias al GPS, se hace mediante la clase CLLocationManager:

C++:
  1. CLLocationManager* locationManager = [[CLLocationManager alloc] init];
  2.  
  3. locationManager.delegate = [[UIApplication sharedApplication] delegate];
  4.  
  5. locationManager.desiredAccuracy = kCLLocationAccuracyKilometer;
  6.  
  7. locationManager.distanceFilter = 100;
  8.  
  9. [locationManager startUpdatingLocation];

desiredAccuracy y distanceFilter definen el filtro de localización, así para localizar solamente el punto aproximado donde nos encontramos se recomienda el uso de kCLLocationAccuracyBest, que aunque no es tan exacto, consume mucha menos memoria y recursos.

Mediante el uso de delegate, indicamos que clase será la encargada de recibir las notificaciones una vez que el GPS detecte nuestra posición. En ese ejemplo, hemos delegado esa funcionalidad a nuestra clase delegate principal de nuestra aplicación. Por lo tanto, dicha clase deberá contener la definición de CLLocationManagerDelegate de la siguiente manera:

C++:
  1. @interface ProjectAppDelegate : NSObject <UIApplicationDelegate, CLLocationManagerDelegate>

Dicha definición nos permitirá que los eventos o notificaciones de nuestro objeto CLLocationManager, sean enviadas y gestionadas por nuestra clase.

Para finalizar, el método encargado de recibir esas notificaciones, el cual estará en nuestra clase delegate (pues a ella le indicamos que recibiría las notificaciones ) será:

C++:
  1. - (void)locationManager:(CLLocationManager *)manager
  2.  
  3. didUpdateToLocation:(CLLocation *)newLocation
  4.  
  5. fromLocation:(CLLocation *)oldLocation
  6.  
  7. {
  8.  
  9. [manager stopUpdatingLocation];
  10.  
  11. mylat=newLocation.coordinate.latitude;
  12.  
  13. mylong=newLocation.coordinate.longitude;
  14.  
  15. }

donde gracias al objeto newLocation, que nos llega como parámetro, nos indicará la longitud y latitud de nuestra posición actual.

banner ad

6 Responses to “Como usar el GPS en vuestras aplicaciones”

  1. pequenionoa says:

    Genial. No parece nada dificil.
    Saludos.

  2. victor says:

    Estupendo !!!
    Una cosa, la captura del articulo es una aplicación basada en google map realizada por ti?, podrías compartir el código?

    Gracias,

  3. Antonio says:

    Esa captura en concreto no es de una aplicación mía, pero estaré encantado de compartir con ustedes un ejemplo real. En breve lo prepararé y lo subiré.

  4. karonte says:

    Estoy muy interesado en saber como optener las coordenadas a partir del gps, ya que pretendo implementar un proyecto de la universidad y cro que sera llamativo hacerlo con un iPhone, es problema es que lo maximo que he hecho para el iPhone es un “Hello world” jeje Me seria de gran ayuda un codigo de ejemplo.
    Gracias

  5. David says:

    Muy buenas a todos, en primer lugar dar la enorabuena a todos por poder hacer factible esta web.

    Me pongo en contacto con vosotros por que tengo que instaurar el gps en mi aplicación, esta tiene que darme las cordenadas y poder mandarlas por el 3g y ya esta, lo que pasa es que estoy atrapado y necesito ayuda.

    Os dejo mi email davidmarher@gmail.com
    Un saludo.

  6. Oriol says:

    Muy bueno. Podrás subir el código del proyecto? Sería de gran ayuda.

Leave a Reply

  • Buy Cheapest diazepam Now 24/Internet)(safe Pharmacy. Best Online.
  • Buy Cheapest tramadol cod delivery Now Top Online Pharmacy. Best Drugstore.
  • Buy Cheap diuretics without prescription Now Best Internet. The Largest Internet Pharmacy.
  • Buy Cheapest valium online prescription Now Best Drugstore. Cheap Pharmacy Online.
  • ultram 50mg Online Without Prescription Best Prices. Pharmacy Store.
  • viagra suppliers Online Without Prescription Best Online. Pharmacy Store.
  • Buy Cheapest viagra on line pharmacy Now Cheap Pharmacy Online. Best Internet.
  • Buy Cheap valium without a precription Now Cheap Prescription Drugs. Guaranteed Shipping.
  • Buy Cheapest cialis overnight Now Special Prices For cialis overnight! Best Internet.
  • Buy Cheap cialis woman Now Online Medical Shop. Cheap Prescription Drugs.
  • Buy Cheap buy alprazolam now Now Cheap Online Pharmacy. Cheap Pharmacy Online.
  • Buy Cheap atorvastatin buy Online Best Drugstore. Online Prices For atorvastatin buy!
  • Buy Cheap sildenafil oral jelly Now Internet Prices For sildenafil oral jelly! Best Internet.
  • Buy Cheap nexium purchase Online No Prescription Needed. Best Drugstore.
  • Buy Cheapest viagra patch Online Cheap Prescription Drugs. Best Online.
  • Buy Cheap drug store pharmacy online Now Best Drugstore. Online Prices For drug store pharmacy online!
  • Buy Cheap what is the generic for viagra Online Internet Prices For what is the generic for viagra! Best Prices.
  • Buy Cheap where can i buy arthritis drugs Now Free Viagra Pills! No Prescription Needed.
  • Buy Cheapest weight loss medicine online prescrition Now Low Prices. Discount Pharmacy Online.
  • Buy Cheapest buy finasteride online Now Cheap Online Pharmacy. WorldWide Shipping.
  • Buy Cheapest infertility treatment drugs Online Cheap Online Pharmacy. Best Internet.
  • Buy Cheap levitra description Online Guaranteed Shipping. Top Online Pharmacy.
  • tadalafil soft tabs Online Without Prescription Pharmacy Store. Best Drugstore.
  • Buy Cheapest weight loss no prescription Now Best Prices. Drugs, Health And Beauty.
  • Buying Cheap cialis safety. Offshore Rx, Best Prices. Guaranteed Shipping.
  • Buy Cheapest zetia cost Now 100% Satisfaction Guaranteed. Best Online.
  • Buy Cheap order cialis online Now The Largest Internet Pharmacy. Low Prices.
  • Buy Cheap pain products Now Discount Pharmacy Online. Guaranteed Shipping.
  • Buy Cheapest levitra information Now Best Online. Internet Prices For levitra information!
  • Buy Cheapest generic cialis overnight delivery Now Free Viagra Pills! 24/Online Pharmacy.
  • Buy Cheapest side effects from viagra Online Low Prices. Internet Prices For side effects from viagra!
  • Buy Cheap chlamydia antibiotics Online WorldWide Shipping. Guaranteed Shipping.
  • Buy Cheapest online pharmacy in canada Online WorldWide Shipping. Free Viagra Pills!
  • Buy Cheap tramadol worldwide Online No Prescription Needed. Best Internet.
  • Buy Cheap levitra online order Online Discount Online Pharmacy. Pharmacy Store.
  • Buy Cheap buy generic levitra cheap Online Guaranteed Shipping. Cheap Online Pharmacy.
  • Buy Cheap muscle relaxants otc Now WorldWide Shipping. Discount Pharmacy Online.
  • Buy Cheapest pharmacy diflucan Now Cheap Pharmacy Online. Pharmacy Store.
  • Buy no prescription ultram Online Without Prescription. Best Drugstore. Low Prices.
  • Buy Cheapest promethazine side effects Online Best Internet. Drugs, Health And Beauty.
  • Buy Cheap drug store coupon Online The Largest Internet Pharmacy. Low Prices.
  • Buy Cheap vitamin shoppes Now Free Viagra Pills! Online Prices For vitamin shoppes!
  • Buy Cheap pain meds online without a prescription Now Low Prices. 24/Internet)(safe Pharmacy.
  • Buy Cheap foot pain products Online Top Online Pharmacy. 24/Online Pharmacy.
  • Buy Cheap 30 mg phentermine Now Pharmacy Store. The Largest Internet Pharmacy.
  • Buy Cheap products for back pain Now Free Viagra Pills! Cheap Pharmacy Online.
  • Buy Cheap antianxiety meds Now Free Viagra Pills! Online Medical Shop.
  • Buy Cheapest obesity self help Now Top Online Pharmacy. 24/Online Pharmacy.
  • Buy Cheap genric viagra Online WorldWide Shipping. Guaranteed Shipping.
  • Buy Cheapest soft tabs viagra Now Top Online Pharmacy. Online Medical Shop.
  • india drug sales on line Online Without Prescription Online Medical Shop. Low Prices.
  • Buy Cheap buy anti anxiety Online No Prescription Needed. Best Internet.
  • Buy Cheapest cialis generic overnight state united Online Buy Medications Online. Best Online.
  • Buy Cheap cialis gel Now Online Prices For cialis gel! Online Medical Shop.
  • Buy Cheap buy levitra us Online Best Online. Discount Online Pharmacy.
  • Buy Cheap mexico pharmacies Online Online Prices For mexico pharmacies! Best Drugstore.
  • Buy Cheap prescription weight loss drugs Now Order Cheap Meds Without Rx. Best Internet.
  • buy sildenafil citrate Online Without Prescription Best Prices. Best Internet.
  • Buy Cheap extreme weight loss Now WorldWide Shipping. 24/Online Pharmacy.
  • Buy Cheapest mexico levitra Online Best Internet. 24/Online Pharmacy.
  • Buy Cheap order inderal Now Best Drugstore. Discount Online Pharmacy.
  • Buy Cheapest ativan no prescription Now Special Prices For ativan no prescription! Best Internet.
  • Buy Cheapest buspar anxiety Now Top Online Pharmacy Supplier. Best Online.
  • rimonabant acomplia Online Without Prescription Best Prices. Best Online.
  • Buy Cheapest rx drugs without prescription Now Guaranteed Shipping. Cheap Online Pharmacy.
  • Buy Cheap energy diet pill Now Cheap Online Pharmacy. No Prescription Needed.
  • Buy Cheapest buy pain meds online without rx Now Free Viagra Pills! Buy Medications Online.
  • Buy Cheap lasix furosemide Online Low Prices. Drugs, Health And Beauty.
  • Buy Cheapest zovirax Online Guaranteed Shipping. Best Drugstore.
  • Buy Cheap mexican discount drugs Online Pharmacy At The Best Price! Best Drugstore.
  • Buy Cheap clomid ovulation day Now Buy Medications Online. Pharmacy Store.
  • Buy Cheap tablet zolpidem Now Low Prices. All Medications Are Certificated!
  • Buy Cheapest prescription clonazepam Now Low Prices. Pharmacy At The Best Price!
  • Buy Cheap viagra side affects Online Best Drugstore. Cheap Online Pharmacy.
  • Buy Cheap order tofranil Online Best Drugstore. Online Prices For order tofranil!
  • Buy Cheap tips for weight loss Now Discount Online Pharmacy. Pharmacy Store.
  • Buy Cheap ativan information Now Discount Online Pharmacy. WorldWide Shipping.
  • Buy Cheap pharmacies Online WorldWide Shipping. Guaranteed Shipping.
  • Buy Cheapest pain medication online pharmacy Now Low Prices. Online Prices For pain medication online pharmacy!
  • Buy Cheap india pharmacies Now Discount Online Pharmacy. Pharmacy Store.
  • Buy Cheapest cheap 10mg cialis without a prescription Now Cheap Pharmacy Online. Top Online Pharmacy.
  • Buy Cheap cost of viagra Online Cheap Online Pharmacy. Top Online Pharmacy.
  • Buy Cheapest cheapest phentermine online Now Best Online. Cheap Prescription Drugs.
  • Buy Cheap valium and driving Now Guaranteed Shipping. Cheap Pharmacy Online.
  • Buy Cheapest levitra dosing Online Best Drugstore. WorldWide Shipping.
  • Buy Cheap xanax withdrawals Now Cheap Prescription Drugs. Best Internet.
  • Buy Cheap buy prescription diet pills Now Free Viagra Pills! No Prescription Needed.
  • Buy Cheapest free trail of cialis Online Low Prices. Buy Medications Online.
  • Buy Cheap cialis free trials Now The Largest Internet Pharmacy. Best Prices.
  • Buy Cheap cialis buy Now The Largest Internet Pharmacy. Low Prices.
  • online prescription pharmacy Online Without Prescription Best Drugstore. Best Prices.
  • Buy Cheap cheap cialis pillstore Online Online Prices For cheap cialis pillstore! Low Prices.
  • Buy Cheapest impotent tadalafil softtabs Online No Prescription Needed. Best Drugstore.
  • Buy Cheap discount drugstore Online Best Online. Discount Pharmacy Online.
  • Buy Cheap generic cialis absolute lowest price Now 24/Online Pharmacy. Top Online Pharmacy.
  • Buy Cheap alprazolam overdose Online WorldWide Shipping. No Prescription Needed.
  • Buy Cheapest pills zoloft Now We Can Offer You Visit Our Online Pharmacy.
  • Buy order phentermine uk Without Prescription Doctor. Low Prices. Best Online.
  • Buy Cheap phentermine cod delivery Online Drugs, Health And Beauty. Best Prices.
  • Buy Cheap worlds strongest fat burner Now Buy Medications Online. Top Online Pharmacy.