Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MapKit in iOS 6 - How to Find Places Nearby...?

Using MapKit in iOS 6, how am I'm supposed to get nearby locations without having their specific coordinates? I'm also unsure if it's still possible...err...allowed...to use Google Maps API to accomplish this goal, as this is the only way I can think of to do this.

I know everything is still in beta, but I've still found no information anywhere about this topic, on forums, in Apple's new MapKit Documentation, anywhere. All I want to do is perform a search for locations (let's say, parks, for example) within 'x' miles of the user's location.

It seems that since Apple has developed their own Maps application, they should have a way to accomplish this using MapKit or Core Location...right?

like image 443
jpcguy89 Avatar asked Nov 03 '22 16:11

jpcguy89


1 Answers

Try with this code. This may help to you.

URLManager *urlmanager = [[URLManager alloc] init];
        urlmanager.delegate = self;
        urlmanager.responseType = JSON_TYPE;
        urlmanager.commandName = @"Search";

NSString *locationString = [NSString stringWithFormat:@"%f,%f",latitude,longitude];
//Location where you want to search

NSString *key = @"AIzaSyCNRpero6aM451X0IfgFHAd-Y3eJUssqoa8`enter code here`0E";
//This is the secret key which you will get from the Google API Console when you register your app.

NSString *radiuos = @"15000";
//This is the area within which you want to search
NSString *keyword = @"Hotel";//Search keyword you want to search

NSMutableDictionary *arguments = [[NSMutableDictionary alloc] init]; // zero argument

[arguments setValue:key forKey:@"key"];

[arguments setValue:locationString forKey:@"location"];

[arguments setValue:radiuos forKey:@"radius"];

[arguments setValue:@"true" forKey:@"sensor"];

[arguments setValue:keyword forKey:@"keyword"];

NSLog(@"Arguments are %@",arguments);

[urlmanager urlCallGetMethod:[NSString stringWithFormat:@"https://maps.googleapis.com/maps/api/place/search/json"] withParameters:arguments];
like image 195
Ravi Patel Avatar answered Nov 15 '22 05:11

Ravi Patel