views:

972

answers:

4

I have made an app that gets an array of addresses from a web service and I want to map them. I know Apple left this out in MapKit, including only a reverse GeoCoder. I was wondering what the best way to approach this problem was. Web Service? Google Maps API (How do API keys work?)? CloudMade?

What is your opinions on which service is fastest, easiest to use, and cheapest (hopefully free)?

Thanks, Conrad Kramer

+1  A: 

I use a "Restful WebService" for Reverse Geocoding using Google Maps and once I get the coordinates I store them in SQLite for later reference. The service returns a JSON string which I later parse in the iPhone.

Something like:

// Initialize call to REST Webservice
- (void) initCall
{
    // Service
    RESTClient *client = [[[RESTClient alloc] initWithDelegate:self] autorelease];
    NSString *serviceHost = @"http://www.site.com/service/maps";
    [client get:serviceHost];
    [serviceHost release];
}

- (void)RESTRequestDidSucceed:(RESTClient*)sender
{

        // Search
   NSString *data = [[[NSString alloc] init] autorelease];
   data = [[NSString alloc] initWithData:sender.receivedData encoding:NSUTF8StringEncoding];

   // Now you have the DATA in and NSString which you can pass as an argument to a method
   // something like

}
JeremySpouken
Sorry, I was looking for geocoding, not reverse geocoding. The iPhone SDK has a built in API for reverse geocoding. If Google maps does do geocoding, is it realistic if I have a LOT of people calling at once? That was more of what I was looking for. What service to use.
ckrames1234
+3  A: 

IANAL, but if the app you're building will be free, then I believe you can use the Google Maps API for free. It's limited to 15,000 geocoding requests per day, but according to the docs, that's tied to IP, not API key. You can get an API key immediately — no approval required. (If your app will not be freely available then you will have to sign up for Google Maps Premier.)

GMaps now has a REST-based geocoding API over HTTP (it used to be you had to use their JavaScript API, which was a pain on iPhone). It can return in JSON, which is trivial to parse using TouchJSON if you need the extra data, or CSV, which will be even easier if all you need is lat/lon. So, you can just create an object that conforms to the MKAnnotation protocol that will fetch the JSON/CSV from the API using an NSURLConnection or ASIHTTPRequest, parse it, and return the Point variable as the coordinate property and build your MapView as required.

Brock Batsell
I really didn't know how API Keys work, and if they do work based on IP, then that solves my problems. Thanks
ckrames1234
Error- The GMaps geocoding /is/ based on IP, it only takes requests from the IP in which the API Key was made for, though
ckrames1234
+3  A: 

The Google Maps API version 3 doesn't require an API key anymore.

Read this: http://blog.sallarp.com/ipad-iphone-forward-geocoding-api-google/

Jesse Armand
Thanks you so much! I would have never known that the new version came out. I have finally found a good solution.
ckrames1234
Is there anyway to geocode multiple addresses in one request? I have an array of places I need to map, and the amount of places can climb into the fifties. I keep getting the error for "too many queries" after the around the tenth one
ckrames1234
I'm not sure about that. I think you need to explore the Maps API regarding multiple requests. I'm quite doubtful they would accept subsequent requests. But, they may have a method to accept multiple addresses. I suggest to contact Google for your problem.
Jesse Armand
A: 

According to both Google and Yahoo, their respective geocoding services DO NOT allow for "storage for future use." Unless I've misunderstood, you cannot store query results into any form of database. Otherwise it'd be really easy to just Google (now 50,000 requests per day).

raj
Yeah, i do not store them. I dynamically fetch them within the app.
ckrames1234