블로그 이미지
박황기
최근에 스마트폰에 관심이 많습니다. 예전에 상상하던 모습들이 점차 이루어지고 있는게 신기하네요.

calendar

1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31

Notice

2010. 5. 14. 15:23 모바일/안드로이드
http://code.google.com/intl/ko/apis/ajaxsearch/documentation/reference.html#_fonje_local

[Local Search]
The Local Search system supports a number of optional arguments which are all listed below:


Argument Description
sll? This optional argument supplies the search center point for a local search. It's value is a comma separated latitude/longitude pair, e.g., sll=48.8565,2.3509.
sspn? This optional argument supplies a bounding box that the local search should be relative to. When using a Google Map, the sspn value can be computed using: myMap.getBounds().toSpan().toUrlValue(); (e.g., sspn=0.065169,0.194149).
mrt? This optional argument specifies which type of listing the user is interested in. Valid values include:
  • blended - request KML, Local Business Listings, and Geocode results
  • kmlonly - request KML and Geocode results
  • localonly - request Local Business Listings and Geocode results
If this argument is not supplied, the default value of localonly is used.



Standard URL Base Address

http://ajax.googleapis.com/ajax/services/search/local


Standard URL Arguments

Each request contains a mix of standard URL arguments and an optional set of searcher specific arguments. This section describes the standard arguments that are uniform across all searchers and that convey virtually identical semantic information to each searcher. In some cases, an argument is optional. This is indicated with a ? following the name of the argument. In all cases, the value of a CGI argument must be properly escaped (e.g., via the functional equivalent of Javascript's encodeURIComponent() method).

The following table lists the standard URL arguments. Additional sections appear below that highlight searcher specific arguments.

Argument Example Description
q q=Paris%20Hilton This argument supplies the query, or search expression, that is passed into the searcher.
v v=1.0 This argument supplies protocol version number. The only valid value at this point in time is 1.0.
userip? userip=192.168.0.1 This argument supplies the IP address of the end-user on whose behalf the request is being made. Requests that include it are less likely to be mistaken for abuse. In choosing to utilize this parameter, please be sure that you're in compliance with any local laws, including any laws relating to disclosure of personal information being sent.
rsz? rsz=small This optional argument supplies the number of results that the application would like to recieve. A value of small indicates a small result set size or 4 results. A value of large indicates a large result set or 8 results. If this argument is not supplied, a value of small is assumed.
hl? hl=fr This optional argument supplies the host language of the application making the request. If this argument is not present then the system will choose a value based on the value of the Accept-Language http header. If this header is not present, a value of en is assumed.
key? key=your-key This optional argument supplies the application's key. If specified, it must be a valid key associated with your site which is validated against the passed referer header. The advantage of supplying a key is so that we can identify and contact you should something go wrong with your application. Without a key, we will still take the same appropriate measures on our side, but we will not be able to contact you. It is definitely best for you to pass a key.
start? start=4 This optional argument supplies the start index of the first search result. Each successful response contains a cursor object (see below) which includes an array of pages. The start property for a page may be used as a valid value for this argument. For reference, a sample cursor object is shown below:
"cursor": {
  "pages": [
    { "start": "0", "label": 1 },
    { "start": "4", "label": 2 },
    { "start": "8", "label": 3 },
    { "start": "12","label": 4 } ],
  "estimatedResultCount": "48758",
  "currentPageIndex": 0,
  "moreResultsUrl": "http://www.google.com/search..."
}
      
callback? callback=foo This optional argument alters the standard response format. When supplied, instead of producing a simple JSON encoded object, the system produces a Javascript function call response where the value of callback specifies the name of the function called in the response.
callbackFunction(
  {"responseData" : {
      "results" : [],
      "cursor" : {}
    },
    "responseDetails" : null | string-on-error,
    "responseStatus" : 200 | error-code
});
      
context? context=bar This optional argument is related to the context argument. When both are supplied, the value of context alters the normal response format associated with callback. The new format is:
callbackFunction(
  contextValue,    // the context arg value
  responseObject,  // the collection of results and cursor
  responseStatus,  // 200 on success, non-200 on failure
  errorDetails)    // error string for non-200 response
      


Standard Response Format

As discussed briefly in the previous section, there are two major variations in the response format. When the callback and context arguments are not supplied, the response format is a simple JSON object:

{
  "responseData" : {
    "results" : [],
    "cursor" : {}
  },
  "responseDetails" : null | string-on-error,
  "responseStatus" : 200 | error-code
}

In the JSON fragment above, note that the responseData property contains a results array and an optional cursor. These are identical both semantically and structurally to the results returned through the JavaScript Searchers layer. The responseStatus property contains a value of 200 on success and a non-200 http error status code on failure. If there is a failure, responseDetails contains a diagnostic string.

By using the callback argument, applications can easily request a JavaScript callback::

callback({ 
  "responseData" : { 
    "results" : [], 
    "cursor" : {} 
  }, 
  "responseDetails" : null | string-on-error, 
  "responseStatus" : 200 | error-code 
});

If the application supplies both callback and context arguments, the response is encoded as a JavaScript procedure call. In this mode of operation, the value of callback becomes the procedure call target, the value of context is passes as the first argument, the value of responseData from above is passes as the second argument, the response status is passed as the third argument, and the final argument is either null or a diagnostic string.

foo('bar',{ 
 "results": [ 
  { 
   "GsearchResultClass": "GwebSearch", 
   "unescapedUrl": "http://en.wikipedia.org/wiki/Paris_Hilton", 
   "url": "http://en.wikipedia.org/wiki/Paris_Hilton", 
   "visibleUrl": "en.wikipedia.org", 
   "cacheUrl": "http://www.google.com/search?q\u003dcache:TwrPfhd22hYJ:en.wikipedia.org", 
   "title": "\u003cb\u003eParis Hilton\u003c/b\u003e - Wikipedia, the free encyclopedia", 
   "titleNoFormatting": "Paris Hilton - Wikipedia, the free encyclopedia", 
   "content": "In 2006, she released her debut album \u003cb\u003eParis\u003c/b\u003e..." 
  }, 
  { 
   "GsearchResultClass": "GwebSearch", 
   "unescapedUrl": "http://www.imdb.com/name/nm0385296/", 
   "url": "http://www.imdb.com/name/nm0385296/", 
   "visibleUrl": "www.imdb.com", 
   "cacheUrl": "http://www.google.com/search?q\u003dcache:1i34KkqnsooJ:www.imdb.com", 
   "title": "\u003cb\u003eParis Hilton\u003c/b\u003e", 
   "titleNoFormatting": "Paris Hilton", 
   "content": "Self: Zoolander. Socialite \u003cb\u003eParis Hilton\u003c/b\u003e was..." 
  }, 
  ... 
 ], 
 "cursor": { 
  "pages": [ 
   { "start": "0", "label": 1 }, 
   { "start": "4", "label": 2 }, 
   { "start": "8", "label": 3 }, 
   { "start": "12","label": 4 } 
  ], 
  "estimatedResultCount": "59600000", 
  "currentPageIndex": 0, 
  "moreResultsUrl": "http://www.google.com/search?oe\u003dutf8..." 
 } 
} 
, 200, null)

 

'모바일 > 안드로이드' 카테고리의 다른 글

SQLite GUI TOOL  (0) 2010.05.16
google code playground  (0) 2010.05.14
에뮬레이터 스킨 수정하기  (0) 2010.05.14
구글맵 문서  (0) 2010.05.10
구글맵 사용시 설정  (0) 2010.05.09
posted by 박황기