Forward geocoding doesnt give correct results

后端 未结 2 851
半阙折子戏
半阙折子戏 2021-01-25 07:31

I didn\'t get correct results for Forward geocoding in certain cases. When I search for some places or hotel it shows result of some others places or areas. I have got following

2条回答
  •  清歌不尽
    2021-01-25 08:10

    I have done what you have asked in one of my apps, but the url is different.

    I am posting the function that gets called each time i input something in a text field.

    -(void) startAutocomplete{
        NSString* baseUrl = [NSString stringWithFormat:@"https://maps.googleapis.com/maps/api/place/queryautocomplete/json?input=%@&key=AIzaSyDz3HAmNY8NsgIhtA8gtbH-QA08Lg9tej4&types=all", self.locationTextfield.text];
    
        NSURL *url = [NSURL URLWithString:[baseUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
        NSLog(@"Url: %@", url);
        NSURLRequest *request = [NSURLRequest requestWithURL:url];
    
        [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
    
            if (connectionError!=nil) {
                [[[UIAlertView alloc] initWithTitle:nil message:connectionError.localizedDescription delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil] show ] ;
            }else{
                NSError *error = nil;
                self.searchResult= [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
    
                //NSLog(@"result:%@",self.searchResult);
                [self.tableView reloadData];
            }
    
        }];
    }
    

提交回复
热议问题