2016-11-12 44 views
1

我在我的應用程序中使用googlemapssdk而不是mapkit,我如何擁有文本字段我必須使用該文本字段來搜索Google地圖中的地點。如何使用uitextfield搜索谷歌地圖中的地方sdk

如何使用文本搜索googlemaps sdk中的地點以及如何獲取搜索到的地點經緯度的特定位置。

我已經經歷了堆棧溢出中的所有問題,但我無法理解它們,所以請幫我解決這個問題。

感謝您的快速解答。

+0

谷歌本身提供了一些用於自動完成搜索的api,您可以使用它們來獲取緯度和更多。 – vaibhav

+0

感謝您快速回復vaibhav,如何使用textfelid進行搜索以及我可以在哪裏獲得apis,請給出鏈接以及如何使用該apis。 –

+0

請參閱此https://www.google.co.in/?gws_rd=ssl#q=google+places+autocomplete+api+example+ios。搜索的地方如何使用的UITextField – vaibhav

回答

0
//You can perform search by tapping search button using the following code 
- (IBAction)searchButtonPressed:(id)sender { 
    [self searchForLocationWithText:self.searchTextField.text]; 
} 


//Else If you want to perform the search on typing each letter, You can use this delegate method 
- (void)textFieldDidChange:(NSNotification *)notification { 
    [self searchForLocationWithText:self.searchTextField.text]; 
} 


//Method for searching 
- (void)searchForLocationWithText:(NSString *)searchString{ 
    GMSCoordinateBounds *bounds = [self getGMSBoundsWithRadiusInMeters:10000]; 
    GMSAutocompleteFilter *filter = [[GMSAutocompleteFilter alloc] init]; 
    [email protected]"IN"; 

    [place_client autocompleteQuery:searchString bounds:bounds filter:filter callback:^(NSArray *results, NSError *error) { 
     //Process result 
    }]; 

} 
+0

感謝 –

+0

@SatheeshkumarNaidu:我剛剛添加代碼,使用textField中的文本進行搜索,並根據上述代碼會給你結果,你必須處理這些結果,像加載本地數組並顯示在tableView中。休息我希望你能理解和照顧。 – Bharath

+0

我必須在谷歌地圖中顯示的搜索結果,例如,如果我搜索印度,我已經在谷歌地圖中顯示印度。您是否擁有任何代碼 –