hi i am giving reference link of stack over flow
Asked
Active
Viewed 126 times
-7
-
i try but i don't know swift. – Bharath Apr 15 '16 at 08:01
-
i am new developer i don't know swift.is there wrong – Bharath Apr 15 '16 at 08:03
-
can you show ur tried code – Anbu.Karthik Apr 15 '16 at 08:04
-
see this once it helps you http://stackoverflow.com/questions/19115293/how-to-smoothly-move-gmsmarker-along-coordinates-in-objective-c – Anbu.Karthik Apr 15 '16 at 08:10
-
Reformat your question and specify what problem you are facing. – Akash KR Apr 15 '16 at 09:40
2 Answers
0
You can try the online swift to objective c converters. Like http://objc2swift.me These converts are used to convert objective c to Swift. I know you want to convert Swift to objective C. But I think you can learn some think to here. Just write the code. Swift is very similar to objective c.Only difference in syntax. You can understand very easily. *Stack Overflow not for Writing Codes. If you have any Problem in codes. We will help you.

Sharat Kannan
- 90
- 2
- 9
0
Here is the code, Create a button, add selector to that button. Hope you will set your google map.
NSMutableData *webData;
@property NSURLConnection *connection;
-(void) getResult //call this in button selector
{
marker=nil; //create a GMSMarker globally.
[self.mapView clear];
NSString *strUrl = [NSString stringWithFormat:@"https://maps.googleapis.com/maps/api/place/search/json?location=%f,%f&radius=%@&type=atm&sensor=true&name=%@&key=%@",latitude,longitude,_radius.text,_searchTxt.text,googleAPI_Key ];
[self addMarkerDataUrl:strUrl];
}
-(void)addMarkerDataUrl:(NSString *)urlString
{
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
NSString* urlTextEscaped = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlTextEscaped]
cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:10];
[request setHTTPMethod: @"GET"];
self.connection = [NSURLConnection connectionWithRequest:request delegate:self];
if(self.connection)
{
webData = [[NSMutableData alloc]init];
}
}
-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
[webData setLength:0];
}
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
[webData appendData:data];
}
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
if (webData)
{
[self gettingData:webData ];
}
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
webData=nil;
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
NSLog(@" response %d",kCFURLErrorNotConnectedToInternet);
if ([error code] == kCFURLErrorNotConnectedToInternet)
{
NSDictionary *userInfo = [NSDictionary dictionaryWithObject:@"No Connection Error"
forKey:NSLocalizedDescriptionKey];
NSError *noConnectionError = [NSError errorWithDomain:NSCocoaErrorDomain code:kCFURLErrorNotConnectedToInternet userInfo:userInfo];
NSLog(@"error %@",noConnectionError);
[self handleError:noConnectionError];
}
else
{
[self handleError:error];
}
self.connection = nil;
[self errorInConnection];
}
- (void)handleError:(NSError *)error
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"SUBCOMMUNE" message:@"Timed Out" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
}
-(void)errorInConnection
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"ERROR" message:@"Try again after some time" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
}
- (void) gettingData:(NSData *)data
{
NSError* error;
NSDictionary* json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
NSArray* places = [json objectForKey:@"results"];
NSLog(@"Google Data: %@", places);
tempArray = [[NSMutableArray alloc]init];
NSDictionary *allDataDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
if([[NSString stringWithFormat:@"%@",[allDataDictionary objectForKey:@"status"]]isEqualToString:@"OK"])
{
collectionArray =[[NSMutableArray alloc]init];
locArray = [[NSMutableArray alloc]init];
NSMutableArray *legsArray = [[NSMutableArray alloc] initWithArray:allDataDictionary[@"results"]];
for (int i=0; i< [legsArray count]; i++)
{
[collectionArray addObject:[NSDictionary dictionaryWithObjectsAndKeys:legsArray[i][@"icon"],@"icon", legsArray[i][@"name"],@"name",legsArray [i][@"vicinity"],@"vicinity",legsArray[i][@"id"],@"id",nil]];
[locArray addObject:legsArray[i][@"geometry"][@"location"]];
[tempArray addObject:legsArray[i][@"vicinity"]];
}
NSLog(@"CollectionArray =%@",collectionArray);
NSLog(@"LocationArray =%lu",(unsigned long)locArray.count);
[self addMarkers];
}
else
{
NSString *msg=[allDataDictionary objectForKey:@"error_message"];
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Error !\n Check Radius or ATM Name" message:msg delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
}
}
-(void)addMarkers
{
for(int i=0;i<locArray.count;i++)
{
starting = [NSMutableDictionary dictionaryWithObjectsAndKeys:locArray[i][@"lat"],@"lat",locArray[i][@"lng"],@"lng", nil];
name = [NSMutableDictionary dictionaryWithObjectsAndKeys:collectionArray[i][@"name"],@"name",nil];
CLLocationCoordinate2D position = CLLocationCoordinate2DMake([[starting objectForKey:@"lat"] doubleValue] , [[starting objectForKey:@"lng"] doubleValue]);
marker1 = [GMSMarker markerWithPosition:position];
GMSCameraUpdate *updatedCamera=[GMSCameraUpdate setTarget:CLLocationCoordinate2DMake(latitude, longitude) zoom:15];
[self.mapView animateWithCameraUpdate:updatedCamera];
marker1.title = [name objectForKey:@"name"];
[marker1 setIcon:[UIImage imageNamed:@"Map Pin-48.png"]];
marker1.appearAnimation = YES;
marker1.map = self.mapView;
}
}

Akash KR
- 778
- 3
- 11