Forward geocoding doesnt give correct results

后端 未结 2 850
半阙折子戏
半阙折子戏 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:01

    You can either take use of the Region Biasing, which according to wiki, should be NP. So add &region=np at the end of your query.

    Or you can use the Viewport Biasing to set the bounds of your searches.

    0 讨论(0)
  • 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];
            }
    
        }];
    }
    
    0 讨论(0)
提交回复
热议问题