쿼리 자동 완성 (레거시)은 사용자가 입력할 때 추천 검색어를 반환하여 텍스트 기반 지리 검색에 대한 쿼리 예측을 제공하는 데 사용할 수 있습니다.
Query Autocomplete (기존) 요청
Query Autocomplete (레거시)은 Places API (레거시)의 일부이며 Places API (레거시)와 API 키 및 할당량을 공유합니다.
Query Autocomplete (레거시)를 사용하면 즉석에서 지리적 쿼리 예상 검색어를 애플리케이션에 추가할 수 있습니다. 특정 위치를 검색하는 대신 사용자가 '뉴욕 근처 피자'와 같은 카테고리 검색을 입력하면 서비스에서 문자열과 일치하는 추천 쿼리 목록을 응답합니다. 쿼리 자동 완성 (레거시)은 전체 단어와 하위 문자열 모두에서 일치할 수 있으므로 애플리케이션은 사용자가 입력할 때 쿼리를 전송하여 즉시 예상 검색어를 제공할 수 있습니다.
질문 자동 완성 (기존) 요청은 다음 형식의 HTTP URL입니다.
https://maps.googleapis.com/maps/api/place/queryautocomplete/output?parameters
여기서 output은 json 또는 xml일 수 있습니다.
Query Autocomplete (기존) 요청을 시작하려면 특정 매개변수가 필요합니다.
URL에서와 마찬가지로 모든 매개변수는 앰퍼샌드(&) 문자를 사용하여 구분합니다. 매개변수 목록과 가능한 값은 아래에 열거되어 있습니다.
필수 매개변수
-
입력
검색할 텍스트 문자열입니다. Place Autocomplete 서비스는 이 문자열을 기반으로 일치 가능성이 있는 항목을 반환하고 감지된 관련성을 기반으로 검색 결과를 정렬합니다.
선택적 매개변수
-
language
결과를 반환할 언어입니다.
- 지원되는 언어 목록을 참고하세요. Google에서는 지원되는 언어를 자주 업데이트하므로 이 목록에 모든 언어가 포함되지 않을 수도 있습니다.
-
language가 제공되지 않으면 API는Accept-Language헤더에 지정된 기본 언어를 사용하려고 시도합니다. - API는 사용자와 현지인 모두가 읽을 수 있는 상세 주소를 제공하기 위해 최선을 다합니다. 이 목표를 달성하기 위해 선호하는 언어를 준수하여 필요한 경우 사용자가 읽을 수 있는 스크립트로 음역된 현지 언어의 거리 주소를 반환합니다. 다른 모든 주소는 기본 언어로 반환됩니다. 주소 구성요소는 모두 첫 번째 구성요소에서 선택한 동일한 언어로 반환됩니다.
- 선호하는 언어로 이름을 사용할 수 없는 경우 API는 가장 일치하는 이름을 사용합니다.
- 기본 언어는 API가 반환하도록 선택한 결과 집합과 반환되는 순서에 약간의 영향을 미칩니다. 지오코더는 언어에 따라 약어를 다르게 해석합니다. 예를 들어 거리 유형의 약어나 한 언어에서는 유효하지만 다른 언어에서는 유효하지 않은 동의어가 있습니다. 예를 들어 utca와 tér은 헝가리어로 거리의 동의어입니다.
-
위치
검색할 지점을
latitude,longitude좌표로 정의합니다. 장소 서비스는 위치를 사용하여location및radius로 정의된 영역의 결과를 우선적으로 표시하도록 검색을 편향시킵니다. 정의된 영역 밖의 결과가 표시될 수도 있습니다.query에Market in Barcelona와 같은 명시적 위치가 포함된 경우location매개변수가 재정의될 수 있습니다. 쿼리 주위에 따옴표를 사용하면location및radius에 부여되는 가중치에도 영향을 줄 수 있습니다. -
오프셋
서비스가 예측을 일치시키는 데 사용하는 마지막 문자의 입력 용어 내 위치입니다. 예를 들어 입력이
Google이고 오프셋이 3이면 서비스는Goo와 일치합니다. 오프셋으로 결정된 문자열은 입력된 용어의 첫 번째 단어와만 일치합니다. 예를 들어 입력된 용어가Google abc이고 오프셋이 3이면 서비스는Goo abc와 일치시키려고 시도합니다. 오프셋이 제공되지 않으면 서비스에서 전체 기간을 사용합니다. 오프셋은 일반적으로 텍스트 캐럿의 위치로 설정해야 합니다. -
반경
장소 결과를 반환할 거리 (미터)를 정의합니다.
location및radius매개변수를 전달하여 특정 원에 편중된 결과를 얻을 수 있습니다. 이렇게 하면 장소 서비스에서 해당 원 내의 결과를 우선적으로 표시합니다. 정의된 영역 밖의 결과가 표시될 수도 있습니다.반지름은 검색 유형 및 기타 매개변수에 따라 최대값으로 자동 제한됩니다.
- 자동 완성: 50,000미터
-
주변 검색:
keyword또는name사용: 50,000미터-
keyword또는name없이-
최대 50,000미터이며,
rankby매개변수와 관계없이 지역 밀도에 따라 동적으로 조정됩니다. -
rankby=distance를 사용하는 경우 반경 매개변수가 허용되지 않으며INVALID_REQUEST이 발생합니다.
-
최대 50,000미터이며,
- Query Autocomplete: 50,000미터
- 텍스트 검색: 50,000미터
Query Autocomplete (기존) 예
URL
https://maps.googleapis.com/maps/api/place/queryautocomplete/json ?input=pizza%20near%20par &key=YOUR_API_KEY
curl
curl -L -X GET 'https://maps.googleapis.com/maps/api/place/queryautocomplete/json?input=pizza%20near%20par&key=YOUR_API_KEY''파리 근처 피자집' 요청(결과는 프랑스어로 표시됨)
URL
https://maps.googleapis.com/maps/api/place/queryautocomplete/json ?input=pizza%20near%20par &language=fr &key=YOUR_API_KEY
curl
curl -L -X GET 'https://maps.googleapis.com/maps/api/place/queryautocomplete/json?input=pizza%20near%20par&language=fr&key=YOUR_API_KEY'이 예의 API 키를 자체 키로 바꿔야 합니다.
Query Autocomplete (기존) 응답
질문 자동 완성 (기존) 응답은 URL 요청 경로 내 output 플래그로 표시된 형식으로 반환됩니다. 아래 결과는 다음 매개변수가 있는 쿼리에 대해 반환됩니다.
URL
https://maps.googleapis.com/maps/api/place/queryautocomplete/json ?input=pizza%20near%20par &key=YOUR_API_KEY
curl
curl -L -X GET 'https://maps.googleapis.com/maps/api/place/queryautocomplete/json?input=pizza%20near%20par&key=YOUR_API_KEY'JSON
{ "predictions": [ { "description": "pizza near Paris, France", "matched_substrings": [{ "length": 5, "offset": 0 }, { "length": 3, "offset": 11 }], "structured_formatting": { "main_text": "pizza", "main_text_matched_substrings": [{ "length": 5, "offset": 0 }], "secondary_text": "near Paris, France", "secondary_text_matched_substrings": [{ "length": 3, "offset": 5 }], }, "terms": [ { "offset": 0, "value": "pizza" }, { "offset": 6, "value": "near" }, { "offset": 11, "value": "Paris" }, { "offset": 18, "value": "France" }, ], }, { "description": "pizza near Pari Chowk, NRI City, Omega II, Noida, Uttar Pradesh, India", "matched_substrings": [{ "length": 5, "offset": 0 }, { "length": 3, "offset": 11 }], "structured_formatting": { "main_text": "pizza", "main_text_matched_substrings": [{ "length": 5, "offset": 0 }], "secondary_text": "near Pari Chowk, NRI City, Omega II, Noida, Uttar Pradesh, India", "secondary_text_matched_substrings": [{ "length": 3, "offset": 5 }], }, "terms": [ { "offset": 0, "value": "pizza" }, { "offset": 6, "value": "near" }, { "offset": 11, "value": "Pari Chowk" }, { "offset": 23, "value": "NRI City" }, { "offset": 33, "value": "Omega II" }, { "offset": 43, "value": "Noida" }, { "offset": 50, "value": "Uttar Pradesh" }, { "offset": 65, "value": "India" }, ], }, { "description": "pizza near Disneyland Park, Disneyland Drive, Anaheim, CA, USA", "matched_substrings": [{ "length": 5, "offset": 0 }, { "length": 3, "offset": 22 }], "structured_formatting": { "main_text": "pizza", "main_text_matched_substrings": [{ "length": 5, "offset": 0 }], "secondary_text": "near Disneyland Park, Disneyland Drive, Anaheim, CA, USA", "secondary_text_matched_substrings": [{ "length": 3, "offset": 16 }], }, "terms": [ { "offset": 0, "value": "pizza" }, { "offset": 6, "value": "near" }, { "offset": 11, "value": "Disneyland Park" }, { "offset": 28, "value": "Disneyland Drive" }, { "offset": 46, "value": "Anaheim" }, { "offset": 55, "value": "CA" }, { "offset": 59, "value": "USA" }, ], }, { "description": "pizza near Cathédrale Notre-Dame de Paris, Parvis Notre-Dame - place Jean-Paul-II, Paris, France", "matched_substrings": [{ "length": 5, "offset": 0 }, { "length": 3, "offset": 36 }], "structured_formatting": { "main_text": "pizza", "main_text_matched_substrings": [{ "length": 5, "offset": 0 }], "secondary_text": "near Cathédrale Notre-Dame de Paris, Parvis Notre-Dame - place Jean-Paul-II, Paris, France", "secondary_text_matched_substrings": [{ "length": 3, "offset": 30 }], }, "terms": [ { "offset": 0, "value": "pizza" }, { "offset": 6, "value": "near" }, { "offset": 11, "value": "Cathédrale Notre-Dame de Paris" }, { "offset": 43, "value": "Parvis Notre-Dame - place Jean-Paul-II" }, { "offset": 83, "value": "Paris" }, { "offset": 90, "value": "France" }, ], }, { "description": "pizza near Paris Beauvais Airport, Route de l'Aéroport, Tillé, France", "matched_substrings": [{ "length": 5, "offset": 0 }, { "length": 3, "offset": 11 }], "structured_formatting": { "main_text": "pizza", "main_text_matched_substrings": [{ "length": 5, "offset": 0 }], "secondary_text": "near Paris Beauvais Airport, Route de l'Aéroport, Tillé, France", "secondary_text_matched_substrings": [{ "length": 3, "offset": 5 }], }, "terms": [ { "offset": 0, "value": "pizza" }, { "offset": 6, "value": "near" }, { "offset": 11, "value": "Paris Beauvais Airport" }, { "offset": 35, "value": "Route de l'Aéroport" }, { "offset": 56, "value": "Tillé" }, { "offset": 63, "value": "France" }, ], }, ], "status": "OK", }
XML
<AutocompletionResponse> <status>OK</status> <prediction> <description>pizza near Paris, France</description> <term> <value>pizza</value> <offset>0</offset> </term> <term> <value>near</value> <offset>6</offset> </term> <term> <value>Paris</value> <offset>11</offset> </term> <term> <value>France</value> <offset>18</offset> </term> <matched_substring> <offset>0</offset> <length>5</length> </matched_substring> <matched_substring> <offset>11</offset> <length>3</length> </matched_substring> <structured_formatting> <description>pizza</description> <subdescription>near Paris, France</subdescription> <description_matched_substring> <offset>0</offset> <length>5</length> </description_matched_substring> <subdescription_matched_substring> <offset>5</offset> <length>3</length> </subdescription_matched_substring> </structured_formatting> </prediction> <prediction> <description>pizza near Pari Chowk, NRI City, Omega II, Noida, Uttar Pradesh, India</description> <term> <value>pizza</value> <offset>0</offset> </term> <term> <value>near</value> <offset>6</offset> </term> <term> <value>Pari Chowk</value> <offset>11</offset> </term> <term> <value>NRI City</value> <offset>23</offset> </term> <term> <value>Omega II</value> <offset>33</offset> </term> <term> <value>Noida</value> <offset>43</offset> </term> <term> <value>Uttar Pradesh</value> <offset>50</offset> </term> <term> <value>India</value> <offset>65</offset> </term> <matched_substring> <offset>0</offset> <length>5</length> </matched_substring> <matched_substring> <offset>11</offset> <length>3</length> </matched_substring> <structured_formatting> <description>pizza</description> <subdescription>near Pari Chowk, NRI City, Omega II, Noida, Uttar Pradesh, India</subdescription> <description_matched_substring> <offset>0</offset> <length>5</length> </description_matched_substring> <subdescription_matched_substring> <offset>5</offset> <length>3</length> </subdescription_matched_substring> </structured_formatting> </prediction> <prediction> <description>pizza near Disneyland Park, Disneyland Drive, Anaheim, CA, USA</description> <term> <value>pizza</value> <offset>0</offset> </term> <term> <value>near</value> <offset>6</offset> </term> <term> <value>Disneyland Park</value> <offset>11</offset> </term> <term> <value>Disneyland Drive</value> <offset>28</offset> </term> <term> <value>Anaheim</value> <offset>46</offset> </term> <term> <value>CA</value> <offset>55</offset> </term> <term> <value>USA</value> <offset>59</offset> </term> <matched_substring> <offset>0</offset> <length>5</length> </matched_substring> <matched_substring> <offset>22</offset> <length>3</length> </matched_substring> <structured_formatting> <description>pizza</description> <subdescription>near Disneyland Park, Disneyland Drive, Anaheim, CA, USA</subdescription> <description_matched_substring> <offset>0</offset> <length>5</length> </description_matched_substring> <subdescription_matched_substring> <offset>16</offset> <length>3</length> </subdescription_matched_substring> </structured_formatting> </prediction> <prediction> <description>pizza near Cathédrale Notre-Dame de Paris, Parvis Notre-Dame - place Jean-Paul-II, Paris, France</description> <term> <value>pizza</value> <offset>0</offset> </term> <term> <value>near</value> <offset>6</offset> </term> <term> <value>Cathédrale Notre-Dame de Paris</value> <offset>11</offset> </term> <term> <value>Parvis Notre-Dame - place Jean-Paul-II</value> <offset>43</offset> </term> <term> <value>Paris</value> <offset>83</offset> </term> <term> <value>France</value> <offset>90</offset> </term> <matched_substring> <offset>0</offset> <length>5</length> </matched_substring> <matched_substring> <offset>36</offset> <length>3</length> </matched_substring> <structured_formatting> <description>pizza</description> <subdescription>near Cathédrale Notre-Dame de Paris, Parvis Notre-Dame - place Jean-Paul-II, Paris, France</subdescription> <description_matched_substring> <offset>0</offset> <length>5</length> </description_matched_substring> <subdescription_matched_substring> <offset>30</offset> <length>3</length> </subdescription_matched_substring> </structured_formatting> </prediction> <prediction> <description>pizza near Paris Beauvais Airport, Route de l'Aéroport, Tillé, France</description> <term> <value>pizza</value> <offset>0</offset> </term> <term> <value>near</value> <offset>6</offset> </term> <term> <value>Paris Beauvais Airport</value> <offset>11</offset> </term> <term> <value>Route de l'Aéroport</value> <offset>35</offset> </term> <term> <value>Tillé</value> <offset>56</offset> </term> <term> <value>France</value> <offset>63</offset> </term> <matched_substring> <offset>0</offset> <length>5</length> </matched_substring> <matched_substring> <offset>11</offset> <length>3</length> </matched_substring> <structured_formatting> <description>pizza</description> <subdescription>near Paris Beauvais Airport, Route de l'Aéroport, Tillé, France</subdescription> <description_matched_substring> <offset>0</offset> <length>5</length> </description_matched_substring> <subdescription_matched_substring> <offset>5</offset> <length>3</length> </subdescription_matched_substring> </structured_formatting> </prediction> </AutocompletionResponse>
장소 서비스가 검색에서 JSON 결과를 반환하면 predictions 배열 내에 배치합니다. 서비스에서 결과를 반환하지 않더라도 (예: location가 원격인 경우) 빈 predictions 배열을 반환합니다. XML 응답은 0개 이상의 <prediction> 요소로 구성됩니다.
PlacesQueryAutocompleteResponse
| 필드 | 필수 | 유형 | 설명 |
|---|---|---|---|
|
required | Array<PlaceAutocompletePrediction> |
예측 배열을 포함합니다. 자세한 내용은 PlaceAutocompletePrediction을 참고하세요. |
|
required | PlacesAutocompleteStatus |
요청의 상태를 포함하며 요청이 실패한 이유를 추적하는 데 도움이 되는 디버깅 정보가 포함될 수도 있습니다. 자세한 내용은 PlacesAutocompleteStatus를 참고하세요. |
|
선택사항 | 문자열 |
서비스가 |
|
선택사항 | Array<string> |
서비스에서 요청 사양에 관한 추가 정보를 반환하는 경우 응답 객체 내에 |
PlacesAutocompleteStatus
서비스에서 반환된 상태 코드입니다.
OK- API 요청이 성공적이었음을 나타냅니다.-
ZERO_RESULTS: 검색이 성공했지만 반환된 결과가 없습니다. 검색에 원격 위치의 경계가 전달된 경우 이 문제가 발생할 수 있습니다. -
INVALID_REQUEST- API 요청이 잘못되었음을 나타냅니다. 일반적으로input매개변수가 누락되었기 때문입니다. -
OVER_QUERY_LIMIT: 다음 중 하나를 나타냅니다.- QPS 한도를 초과했습니다.
- 계정에 결제가 사용 설정되어 있지 않습니다.
- 월 $200 크레딧 또는 자체 설정 사용량 한도를 초과했습니다.
- 제공된 결제 수단이 더 이상 유효하지 않습니다 (예: 신용카드가 만료됨).
-
REQUEST_DENIED- 요청이 거부되었음을 나타냅니다. 일반적으로 다음과 같은 이유 때문입니다.- 요청에 API 키가 누락되었습니다.
key매개변수가 잘못되었습니다.
UNKNOWN_ERROR- 알 수 없는 오류를 나타냅니다.
장소 서비스가 검색에서 JSON 결과를 반환하면 predictions 배열 내에 배치합니다. 서비스가 결과를 반환하지 않더라도 (예: location이 원격인 경우) 빈 predictions 배열을 반환합니다. XML 응답은 0개 이상의 <prediction> 요소로 구성됩니다.
PlaceAutocompletePrediction
| 필드 | 필수 | 유형 | 설명 |
|---|---|---|---|
|
required | 문자열 |
반환된 결과의 사람이 읽을 수 있는 이름을 포함합니다. |
|
required | Array<PlaceAutocompleteMatchedSubstring> |
입력된 용어의 위치를 예측 결과 텍스트에 설명하는 하위 문자열 목록입니다. 원하는 경우 용어를 강조 표시할 수 있습니다. 자세한 내용은 PlaceAutocompleteMatchedSubstring을 참고하세요. |
|
required | PlaceAutocompleteStructuredFormat |
자동 완성 결과에 표시할 수 있는 사전 형식화된 텍스트를 제공합니다. 이 콘텐츠는 있는 그대로 읽어야 합니다. 형식이 지정된 주소를 프로그래매틱 방식으로 파싱하지 마세요. 자세한 내용은 PlaceAutocompleteStructuredFormat을 참고하세요. |
|
required | Array<PlaceAutocompleteTerm> |
반환된 설명의 각 섹션을 식별하는 용어 배열을 포함합니다. 설명의 섹션은 일반적으로 쉼표로 종료됩니다. 배열의 각 항목에는 용어의 텍스트를 포함하는 자세한 내용은 PlaceAutocompleteTerm을 참고하세요. |
|
선택사항 | 정수 |
원점으로부터의 직선 거리(미터)입니다. 이 필드는 |
|
선택사항 | 문자열 |
장소를 고유하게 식별하는 텍스트 식별자. 장소에 관한 정보를 가져오려면 Places API 요청의 placeId 필드에 이 식별자를 전달하세요. 장소 ID에 대한 자세한 내용은 장소 ID 개요를 참고하세요. |
|
선택사항 | 문자열 |
place_id를 참고하세요. |
|
선택사항 | Array<string> |
이 장소에 적용되는 유형의 배열을 포함합니다. 예를 들면 |
PlaceAutocompleteMatchedSubstring
| 필드 | 필수 | 유형 | 설명 |
|---|---|---|---|
|
required | 숫자 |
예측 결과 텍스트에서 일치하는 하위 문자열의 길이입니다. |
|
required | 숫자 |
예측 결과 텍스트에서 일치하는 하위 문자열의 시작 위치입니다. |
PlaceAutocompleteStructuredFormat
| 필드 | 필수 | 유형 | 설명 |
|---|---|---|---|
|
required | 문자열 |
예측의 기본 텍스트(일반적으로 장소 이름)가 포함됩니다. |
|
required | Array<PlaceAutocompleteMatchedSubstring> |
자세한 내용은 PlaceAutocompleteMatchedSubstring을 참고하세요. |
|
선택사항 | 문자열 |
예측의 보조 텍스트(일반적으로 장소의 위치)가 포함됩니다. |
|
선택사항 | Array<PlaceAutocompleteMatchedSubstring> |
자세한 내용은 PlaceAutocompleteMatchedSubstring을 참고하세요. |
PlaceAutocompleteTerm
| 필드 | 필수 | 유형 | 설명 |
|---|---|---|---|
|
required | 숫자 |
설명에서 이 용어의 시작 위치를 정의합니다(유니코드 문자로 측정). |
|
required | 문자열 |
용어의 텍스트입니다. |