Google Maps API for iOS with Interface Builder

Today, Google released the Google Map API for iOS. Here you can find all the necessary information you need. You have to register and get the API Key as usual.

In the section “Adding the Google Maps SDK for iOS to your project”, they explain how to build a simple example. However, they add the map view programmatically. If you are like me that prefer using Interface Builder, follow these steps to fix this.

After you add the framework to your project, open the view controller in which you want to add the map. Then, go to the main view controller view and add a new view (a UIView object). Select the view and in the Identity Inspector (next figure), change the class from UIView to `GMSMapView’. If you want, you can also change the name of the object fixing the Label to GMSMapView.

Now, you simply treat this view as the standard Apple MKMapView. You can add an outlet to your code and from there do the rest of you work.
I am attaching here an example show this. Don’t forget to add your API key in the application:didFinishLaunchingWithOptions: of the App delegate.

The same solution works for the iPad. Just add to the iPad app the view as shown above and you are done.




(Visited 71 times, 1 visits today)