Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Integrate Google Maps API into an iPhone app

Update: iPhone SDk 3.0 now addresses the question here, however the NDA prevents any in depth discussion. Log in to the iPhone Dev Center if you need more info.

Ok, I have to admit I'm a little lost here.

I am fairly comfortable with Cocoa, but am having trouble picking up the bit of javascript needed to solve this problem.

I am trying to send a request to Google for a reverse geo code.

I have looked over the Google documentation I have viewed here: http://code.google.com/apis/maps/documentation/index.html http://code.google.com/apis/maps/documentation/geocoding/

Even after a rough reading, I am missing a basic concept:

How do I talk to google? In some examples, they show a url being sent to google (which seems easy enough), but in others they show javascript. It seems for reverse geocoding, the request might be be harder than sending the url with some parameters (but I hope I am wrong).

Can someone point me to the correct way to make a request? (In objective-C, so I can wrap my head around it)

like image 782
Corey Floyd Avatar asked Feb 16 '09 00:02

Corey Floyd


People also ask

Can I integrate Google Maps in my app?

Android allows us to integrate google maps in our application. You can show any location on the map , or can show different routes on the map e.t.c. You can also customize the map according to your choices.

Is google map API free for iOS?

The google maps iOS sdk is free for use.


2 Answers

UPDATE - iPhone 0.3 includes MapKit, which will hopefully be significantly faster than using the JS API. The blurb says that it will include reverse geocoding.

You can't make a request directly in objective-C, at least not within the terms of the Google API. The Google API is written in Javascript. You could use an objective-c to JS bridge, as the Google Maps Component does, but that doesn't really solve the issue - you're still making JS calls!

Unfortunately, that means you a) need to use a webview b) need to use the JS API which is slow... compare with the Google Maps application which uses a completely different OTA protocol (try packet sniffing it).

The Google Maps Component is, however, a useful tutorial in how to make simple calls to the API.

like image 76
Airsource Ltd Avatar answered Oct 13 '22 03:10

Airsource Ltd


I have created SVGeocoder, a simple forward and reverse geocoder class for iOS. It uses the Google Geocoding API, returns SVPlacemark objects (an MKPlacemark subclass with a coordinate property) and uses blocks.

This is how you geocode an address string:

[SVGeocoder geocode:addressString
         completion:^(NSArray *placemarks, NSError *error) {
             // do something with placemarks, handle errors
         }];

You can also reverse geocode a coordinate like this:

[SVGeocoder reverseGeocode:CLLocationCoordinate2DMake(45.53264, -73.60518)
                completion:^(NSArray *placemarks, NSError *error) {
                    // do something with placemarks, handle errors
                }];
like image 36
samvermette Avatar answered Oct 13 '22 03:10

samvermette