Category: Apps

Weather has always been unpredictable, just ask anyone who lives in Florida. However, when we look at patterns we can “sorta” predict weather. There is an app in the Windows Store that looks at these patterns to display rising rivers in your area. Why is this useful? Well, have you seen what happened in Colorado or even in Austin?

Fluvium(Fluvial – term used in geography and Earth science to refer to the processes associated with rivers and streams and thedeposits and landforms created by them – Wikipedia) allows you to find nearby rivers and add them to your watch list. Data comes in from the USGS is updated every fifteen minutes, providing close to real-time monitoring. There are thousands of USGS monitored sites that you can choose from and add in Bing Maps integration to give you a pinpoint view of the area.

IconMaker is a tool for people making Windows 8 apps. Many different sized icons are needed for finishing and submitting a Windows 8 app to the store. This will load an image from your Picture Library and save off .PNG files for the needed sizes.

I am integrating the Google Places API into an iPhone app that I am building. I found an existing library that uses Google Local Search but that is deprecated. So I forked that solution and came up with Google Places Library.

As the story goes…when the application is configured to allow current location, the fun begins.

First configure your project to include the CoreLocation and the MapKit framework. I am using a single view project for this example but it can be any project really.

In the RootViewController I need to define some delegates. Since I will be embedding a UITableView and UISearchBar I need the following to be added: <UITextFieldDelegate, UITableViewDelegate, UITableViewDataSource, UISearchBarDelegate, CLLocationManagerDelegate, GooglePlacesConnectionDelegate>

UITableViewDelegate – will help populate the data on my table.

UISearchBarDelegate – will perform some interactions with the searching of places

CLLocationManagerDelegate – will get the location

GooglePlacesConnectionDelegate – will perform the main search

Once that is complete I can then add some outlets for my UI and set up some properties.

JavaScript

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

#import

#import

#import"GooglePlacesConnection.h"

@classGooglePlacesObject;

@interface RootViewController :UIViewController

{

IBOutlet UITableView*tableView;

IBOutlet UIButton*btnCancel;

IBOutlet UISearchBar*searchBar;

CLLocationManager*locationManager;

CLLocation*currentLocation;

NSMutableData*responseData;

NSMutableArray*locations;

NSString*searchString;

GooglePlacesConnection*googlePlacesConnection;

}

@property(nonatomic,getter=isResultsLoaded)BOOLresultsLoaded;

@property(nonatomic,retain)CLLocationManager*locationManager;

@property(nonatomic,retain)CLLocation*currentLocation;

@property(nonatomic,retain)NSURLConnection*urlConnection;

@property(nonatomic,retain)NSMutableData*responseData;

@property(nonatomic,retain)NSMutableArray*locations;

@end

Lets move on to the meat and potatoes of this app. Within the .m file I need to initialize some of my variables and get the GoogleConnection going.

The next method really starts the fun. In my case I am constructing a URL for the Google Places API. If you are not familiar with it you can find more about it here. The url takes the following parameters:

key: required – your API key

location: required – latitude/longitude around which to retrieve Place information. Location manager will help here

radius: required – distance in meters. For the initial search I have 500, for the UISearchBar I moved it out to 1000.

sensor: required – needs to be set to TRUE if came from a device with a location sensor

I am not going to dive deep into the GooglePlacesConnection class or the GooglePlacesObject. However I will say this, the GooglePlacesObject is just that. An object of the Google Place. It has an init that will take the dictionary object from the JSON results. The GooglePlacesConnection does the work of constructing of the URL and issuing the request. One thing to note, the only error checking on the Google Place request is if there are 0 results or an error with the URL or request. There are other status codes if you want to add them in if needed.

Back into the RootViewController.m, we now should have a locations NSMutableArray so we can now populate our UITableView.

The second, third and fourth method handle the interaction with the UISearchBar itself. Each calls the updateSearchString method and passes in the text from the search bar. updateSearchString performs a similar search to the location manager search, except it is passing in the search string as well. If you look in the GooglePlacesConnection method I am also expanding the search radius to 1000 from 500.