Places API Reference

Contents

UI API

 
nokia

Data API

 
nokia

jsMotif

 
jsMotif

Class nokia.places.SearchBox

Class Summary

This class represents a UI widget that provides access to the Places API search functionality. The class allows a Web site user to search for places (locations) and view the results. It offers suggestions when the user begins to type a search term, handles the search itself and displays the results in a designated element on a Web page.

new nokia.places.SearchBox (params)

Method Summary

This method aborts the current suggestion and search request.
This method hides a suggestion list.
navigateList (direction)
This method navigates suggestion list using parameter (positive 'up', negative 'down').
search ()
This method runs a search, using the current value in the widget's input field.
select (term)
This method sets the provided term into the input field.
setCurrentLocation (location)
This method sets the current geographical position in terms of latitude and longitude.
This method shows a suggestion list.
suggest ()
This method runs a suggestion search, using current value in the input field, and causes the results to be displayed as a list of suggestions.

Constructor Detail

This class represents a UI widget that provides access to the Places API search functionality. The class allows a Web site user to search for places (locations) and view the results. It offers suggestions when the user begins to type a search term, handles the search itself and displays the results in a designated element on a Web page.

new nokia.places.SearchBox(params)
Parameters:
{Object} params
An initialization object that can include parameters for nokia.places.Widget, as well as the following optional properties:
  • searchCenter - a caller-defined function that retrieves an object containing the geographical coordinates of the search center (searches are conducted in widening circles around this location and the results are ordered by relevance to the search criteria); if provided, useGeoLocation is ignored; the function is expected to return an object with the following properties:
    • latitude - latitude of the center point for the search
    • longitude - latitude of the center point for the search
  • useGeoLocation - {Boolean}, if true and the browser supports the W3C Geolocation API and searchCenter is not provided, Places search tries to use the W3C Geolocation API to get the client location and use it as the search center; if this parameter is false and searchCenter is not provided, a global search is executed
  • map - an optional reference to a Nokia's Maps API map object; when specified instead of searchCenter, SearchBox reads the location of the search center from the map, updating it as the user pans or move the map
  • onResults - a caller-defined callback function to be invoked after the search results become available; the function is invoked only if onSelect is not defined; the function receives the results of a search based on the user-selected search term as an array of data structures; these can be wrapped in instances of nokia.places.models.PlaceModel) and you can then use a Place instance to retrieve place data, using the ids of the items in the received array
  • onSearchStart - a caller-defined callback function to be invoked when the search is being fired
  • placeList - a reference to o PlaceList widget @link {nokia.places.PlaceList} if provided SearchBox widget will \ use existing place list widget to render results
  • suggestions - an optional object whose properties (also optional) define the composition of the search term suggestions list displayed to the user and functions that handle suggestions
    • limits - an optional object containing properties that define the composition of the list of suggestions displayed to the user
      • maxSuggestions - (optional) the maximum number of suggestions to show in the suggestions list when the user starts typing a new search term; the default value is 4
      • maxSearched - (optional) maximum number of suggestions based on previous searches to show in the suggestions list, the default value is 2
      • maxFavorites - (optional) maximum number of suggestions based on favorites to show in the suggestions list, the default value is 1
      • maxSaved - (optional) maximum number of suggestions from local storage (previously entered search terms) to be included in the suggestion list displayed when the user starts typing a new search term, the default value is 3
    • handlers
      • onSuggestions - an optional caller-defined callback function to be invoked when when suggestions are returned by the server; the function must accept an array of objects containing the suggestions
      • onSearchSuggestions - an optional caller-defined calback function to be invoked when search suggestions are returned by the server; the function must accept an array of objects search suggestions
      • onSelect - an optional caller-defined function to be invoked when the Web user selects a suggestion; the function must be able to accept two arguments: a search term ({String}), and an object ({Object}) representing the search results; the search results object is populated with real search results data if maxSearched is non-zero, thus allowing the search data to appear in the displayed suggestions list; note that if provided, the onSelect function prevents execution of onResults and thus overrides the default behavior of SearchBox
    • favourites - an optional function that can be defined by the caller; if provided, it returns a list of favorites
    • keyInterval - an optional {Number} value that indicates how much time to allow the user to enter suggestions (in milliseconds) before firing a request (this allows you to avoid firing a request for each letter the user types)
    • showAddress - a Boolean value that indicates whether to show the street address in the list of suggestions when maxSearched is greater than zero

Method Detail

abortRequest ()
This method aborts the current suggestion and search request. A suggestion request is typically fired after the third character has been entered into the search box and the results (suggestions) are displayed in a drop-down box, but if this method is used no suggestion search is run and no suggestions are displayed. Similarly, if the method is called after the user has hit return after entering a search term, the search is cancelled and no results are displayed.
hideSuggestions ()
This method hides a suggestion list.
navigateList (direction)
This method navigates suggestion list using parameter (positive 'up', negative 'down').
Parameters:
{Object} direction
search ()
This method runs a search, using the current value in the widget's input field.
select (term)
This method sets the provided term into the input field.
Parameters:
{Object} term
The search term to place in the input field
setCurrentLocation (location)
This method sets the current geographical position in terms of latitude and longitude.
Parameters:
{Object} location
A geo position object, containing the latitude and longitude for example {latitude: 111, longitude: 222}
showSuggestions ()
This method shows a suggestion list.
suggest ()
This method runs a suggestion search, using current value in the input field, and causes the results to be displayed as a list of suggestions.

Copyright © 2011 Nokia. All rights reserved. Terms and Conditions