Your Location + SimpleGeo
So, if you haven't noticed there are quite a few apps out there that use GeoLocation as their main mode of interaction. User's create spots and checkin to different places winning digital items, badges, or mayorships as they go. If you want to start playing with GeoLocation and CodeIgniter then this is the post for you.
First things first, I'm going to use Safari and SimpleGeo for this post, so to follow along you need to make sure your browser supports "navigator.geolocation". Head over to the SimpleGeo site and sign up for a free account.; you will also need to install their PEAR package Services_SimpleGeo according to the directions in it's readme. I've had problems were it won't install due to a date in the package.xml file, so you may need to update the date tag to show today's date for it to install correctly. Once you get that installed create a new CodeIgniter project however you normally do (that's right, I'm not making you follow my CI app setup).
Once you've setup your app we're going to need to setup a quick view file:
Save the view as geo.php and then we're going to create a controller to show the view and to access the SimpleGeo API. For the sake of the tutorial I'm calling my controller geo.php as well. You'll need your OAuth Token and Secret from this page to access the API; as well as the Business Listings layer which you can get for free (at the time of I'm writing this post) at the SimpleGeo Marketplace.
Now that the controller is ready to be used we need to add download jQuery and create a app.js file.
Then we just need to add the script tags to the bottom of our geo.php view file. If you browse to controller in your navigator.geolocation enabled browser you should see something similar to the image below:
This is a very simple example of using SimpleGeo and CodeIgniter together you can do much more with the API than just getting nearby businesses and I encourage you to go play around with their API some more. This is a blog about CodeIgniter, but they also have API clients for other languages, so if you need geo services in .NET, Java, or the iPhone they've got you covered.





Comments 7 Comments
@Josh: awesome! thank's four the info, and i love youre use of apostrophe's
@discern Whoops. I was typing this in Textmate and it doesn't always understand when I want an apostrophe and when I want single quotes. Will fix those issues now.