background preloader

Geolocation

Facebook Twitter

Core Location Tutorial. Developing iOS apps that can take advantage of the built-in GPS unit is a great way to add a new dimension to the user experience.

Core Location Tutorial

You can quickly make your apps location-aware (and able to find the current latitude/longitude coordinates) with minimal effort. This tutorial will walk through the steps involved in finding a device’s current position. In iOS, you can find the current lat/lng by making a request to the Core Location component to start looking up location information. This works via a series of delegate messages passed to our application when Core Location starts updating.

By default, the location hardware in our device is usually turned off (or otherwise in an idle state) so as not to needlessly drain power. #import the correct Core Location header fileLink against the Core Location frameworkImplement two delegate methods to receive information from Core LocationTell Core Location to start sending us updatesProperly shut down Core Location when we don’t need it anymore. Core Location with NSTimer. Yesterday, I posted a tutorial on getting started with Core Location.

Core Location with NSTimer

Be sure to check it out if you haven’t already. One of the comments we received pointed out that it would be a good idea to also have an NSTimer running to stop the Core Location updates should we never receive a location with a good-enough accuracy. This prevents the case where the device keeps Location Services powered up (such as the GPS and radio) and drawing power.

Let’s take a look at how to implement this timer: First, setup an NSTimer class variable in the same class where you’re using the CLLocationManager: Be sure to include the corresponding @synthesize. This method does two things. Lastly, this method invalidates the NSTimer object as we no longer need it. One last note: we also want to stop this timer should we unload our view (remember that we’re already stopping Core Location updates in our viewDidUnload method). Starting the Timer Great, now let’s kick off the timer. Hope you find this helpful. SimpleGeo. Mobile apps that are geographically-aware are all the rage these days, and there’s a number of ways to jump into this new geo-world we live in.

SimpleGeo

One of the more interesting ones is SimpleGeo. They’re a startup in San Francisco that provides a number of APIs for doing geo-related things (like geofencing, and reverse geocoding which we’ll take a stab at today). Although they have a pretty decent iOS framework, there is next to zero documentation on how to use it. So I thought I’d write a simple app demonstrating how to do a reverse geocode (and retrieve the current weather) using SimpleGeo.framework.

Here’s the process: Get the current lat/lng using the built-in iOS Core Location framework.Create an SGPoint using the lat/lng.Setup SimpleGeo with your API keysPass the SGPoint to getContextForPoint, with ourselves as a delegate A Little Background First Why would we want to use SimpleGeo to do a reverse geocode in the first place? Getting Started Where Am I? Setting Up SimpleGeo. Introduction to MapKit Framework for iPhone Development. Maps are important part of our life.

Introduction to MapKit Framework for iPhone Development

We use them daily to find places and directions. The MapKit framework makes it easy for developers to implement applications which can make use of the maps in the applications. In this article we are going to introduce the MapKit framework for iOS programming. Concepts: There are several concepts that we must learn first before diving into the code.

MKMapView: MKMapView is a UI control which is used to display map in iOS devices. Annotation: Annotations is information related to a particular place on the map. AnnotationView: The visual appearance of Annotations are defined using the MKAnnotationView class. Referencing the Frameworks: For this application we will be using the MapKit.framework and CoreLocation.framework.