user2511118
user2511118

Reputation: 47

Google maps api for iOS using storyboard

i'm trying to add Google map to my app in map view and i want to put features like the one that in whatsapp. By providing the near places , search bar and share my current location. Can any body help me and tell me if there is something i need to buy or request from Google or anywhere?

Upvotes: 1

Views: 2478

Answers (2)

wendelbsilva
wendelbsilva

Reputation: 772

Initially, to get the map running, you can follow the steps shown in this page

With Google Places API you can search for nearby places in a given position. Or you can search for locations based on a string.

To get your current location, you can see how to do it here.

You dont have to buy anything. Although, Google API has limitations of access. For example, The Google Places only allow you to do 1,000 requests a day. The Google Maps SDK for iOS do not limit the request.

Here is a snippet of a code of mine to access the Google Places API.

NSString * key = @"PUT YOUR KEY HERE";
NSString * html_msg = [msg stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
NSString * address = [NSString stringWithFormat: @"https://maps.googleapis.com/maps/api/place/textsearch/json?sensor=false&key=%@&query=%@", key, html_msg];
//Create URL and Request
NSURL * url = [NSURL URLWithString:address];
NSURLRequest * request = [NSURLRequest requestWithURL:url];
NSURLResponse * response;
NSError * error = nil;
//Send Request
NSData * data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
if (error == nil) {
    //Parse JSON to Dictionary
    NSDictionary * json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
    //Get the lat/lng of the first result
    [json[@"results"][0][@"geometry"][@"location"][@"lat"] doubleValue];
    [json[@"results"][0][@"geometry"][@"location"][@"lng"] doubleValue];
}

Upvotes: 1

austin-schick
austin-schick

Reputation: 1245

I'm not sure what features are included in whatsapp, but a google search tells me that there is a Google Maps SDK, with features that should allow you to create a "highly interactive" app. It doesn't seem to cost anything, but you do need to credit Google. Here's the link to their website: https://developers.google.com/maps/documentation/ios/

Upvotes: 1

Related Questions