ALKMaps.Control.SingleSearch

  • This control is for single search.
  • Inherits from:
*ALKMaps.Control
Summary
ALKMaps.Control.SingleSearch
Properties
events{ALKMaps.Events}
componentLocationPossible values like “topleft”, “topright”, “bottomright”, “bottomleft”.
componentWidthPossible values like “narrow”, “wide”.
divDiv containing the control.
doneTypingInterval{Number} Done typing interval.
placeholderText{String} Place holder text for the search box.
minSearchTextLength{Number} If search text is longer than this value, then starts search.
Constants
DEFAULT_SEARCH_OPTION{Object} Default search settings.
Properties
searchOption{Object} Search option.
locationRelevance{String} Map viewport center or device location may be used.
hideResults{Boolean} Hide results list or not when a result item is clicked on or enter key is pressed on a focused item.
geocodingLayer{ALKMaps.Layer.VectorMarkers} Location marker will be drawn on this layer.
classNamePrefix{String} CSS class name prefix.
markerStyle{Object} Marker style.
markerConfig{Object} Location marker configuration.
popupConfig{Object} Popup property configuration.
displaySystem{String} Show distance in KM or Miles.
Functions
destroyDestroy control.
activateActivates the control.
deactivateDeactivates the control.
setMapSets map and the geocoding layer to the map.
drawDraws the control.
createResultElementConstruct HTML LI item.
setSearchOptionUpdates search option.
searchCompletedDefault method for handling successful search.
searchFailedDefault method for handling failed search.

Properties

events

{ALKMaps.Events}

Supported event types

locationfailedtrigged when browser’s geolocation failed.  It can be caused by HTTPS is not enabled.  The event object will include a error property that references the error.
searchcompletedtriggered when the control receives results from the single search web service before the control starts to show results.  The event object will include a locations property that references the results.  When a listener returns “false”, the step of showing results list will be skipped.
resultslistdrawntriggered after results list is shown.  The event object will include a locations property that reference the search results.  By adding a listener, user may be able to frame locations on the map as an example.
locationclicktriggered when user clicks on a location item on the displayed results list.  The event object will include a location property that references the location.  When a listener returns “false”, the step of showing the location marker on the map will be aborted.
locationentertriggered when user presses enter key if the location item has the focus.  The event object will include a location property that references the location.  When a listener returns “false”, the step of showing the location marker on the map will be aborted.
resultslistescapetriggered when ESC key is pressed if any location item has the focus.  The event object will include a resultsListElement property that references the UL DOM element.  When a listener returns “false”, the step of hiding results list process will be aborted.
beforeprocessresponseitemtrigged before a location marker with an optional popup is added to the map.  The event object will include a location property that references the location.  When a listener returns “false”, the step of showing the location marker on the map will be aborted.  By handling this event, user does not need to handle locationclick and locationenter separately.
locationblurtriggered when a location item in the displayed list loses focus.  The event object will include a location property that references the location.  When a listener returns “false”, the activate keyboard control process will be aborted.
locationfocustriggered when a location item in the displayed list gets focus.  The event object will include a location property that references the location.  When a listener returns “false”, the deactivate keyboard control process will be aborted.
beforegeticontriggered when showing location results list or showing location marker on the map.  The event object will include a location property that references the location.  If a listener returns an icon path, this icon will be used instead of the application default icon.  Be aware that if markerStyle.externalGraphic is supplied, it will be used to draw the location marker.

componentLocation

Possible values like “topleft”, “topright”, “bottomright”, “bottomleft”.  Any value can be passed in as long as it matches the value in the CSS file.  Inside the control “alkmaps-” is added in front of the value supplied, like “alkmaps-topleft”.

componentWidth

Possible values like “narrow”, “wide”.  Any value can be passed in as long as it matches the value in the CSS file.  Inside the control “alkmaps-geo-” is added in front of the value supplied, like “alkmaps-geo-wide”.

div

Div containing the control.  If an external div is provided, it will be stored in this property.

doneTypingInterval

{Number} Done typing interval.  Default is 700 milliseconds.

placeholderText

{String} Place holder text for the search box.

minSearchTextLength

{Number} If search text is longer than this value, then starts search.

Constants

DEFAULT_SEARCH_OPTION

{Object} Default search settings.  Region is NA.  Max results count is 20.  Excluded search types are POI, POITYPE.  You can change search options by using the searchOption property or call setSearchOption method.

Properties

searchOption

{Object} Search option.

query{String} If it is not null, search text box input will be ignored.
maxResults{Number} Maximum returned results.  Default is 20.
currentLonLat{ALKMaps.LonLat} Current longitude and latitude values in degrees.  If it is supplied, it has higher priority.  If not, the reference longitude and latitude will be based on the locationRelevance setting.
excludedSearchTypes{String} Comma-separated list of types to exclude from the search.  Default is “POI,POITYPE”.  To get all types, you can call ALKMaps.Geocoder.singleSearchGet(‘types’) method.
poiCategories{String} Comma-separated list of poi category names by which you want to filter all POI results.  To get all categories, you can call ALKMaps.Geocoder.singleSearchGet(‘poiCategories’) method.
countries{String} Comma-separated list of country abbreviations by which you want to filter all results.  To get all countries, you can call ALKMaps.Geocoder.singleSearchGet(‘countries’) method.
countryType{String} ISO, FIPS, GENC2, GENC3.  To get all types, you can call ALKMaps.Geocoder.singleSearchGetCountryTypes() method.
states{String} Comma-separated list of state abbreviations by which you want to filter all results.  To get all states, you can call ALKMaps.Geocoder.singleSearchGet(‘states’) method.
region{String} NA, EU, WW.  To get supported regions, you can call ALKMaps.Geocoder.singleSearchGetRegions() method.
async{Boolean} Open an asynchronous request.  Default is true.
success{Function} To overwrite default handler, supply custom method here.
failure{Function} To overwrite default handler, supply custom method here.

locationRelevance

{String} Map viewport center or device location may be used.  Available values are “mapCenter”, “device”, or null.  Default is null.  If you want to get device location, HTTPS has to be enabled.

hideResults

{Boolean} Hide results list or not when a result item is clicked on or enter key is pressed on a focused item.  Default is false.

geocodingLayer

{ALKMaps.Layer.VectorMarkers} Location marker will be drawn on this layer.

classNamePrefix

{String} CSS class name prefix.  Default is empty string.

markerStyle

{Object} Marker style.  When you create an instance of this control, setup this property.  Changing this property after initialization may cause undesired effects.

externalGraphic{String} If the URL is supplied, it will replace default icon.  Default is null and the control will choose icon for the marker.
graphicHeight{Number} Marker height.  Default is 26 pixel.
graphicWidth{Number} Marker width.  Default is 26 pixel.
graphicXOffset{Number} Marker x-direction offset.  Default is -13.
graphicYOffset{Number} Marker y-direction offset.  Default is -13.

markerConfig

{Object} Location marker configuration.  When you create an instance of this control, setup this property.  Changing this property after initialization may cause undesired effects.

exclusive{Boolean} If true, erases all other marker first.  Default is true.
centerOnMap{Boolean} Center the marker on the map.  Default is true.
zoomLevel{Number} Zoom level is used for centering the marker.

popupConfig

{Object} Popup property configuration.  When you create an instance of this control, setup this property.  Changing this property after initialization may cause undesired effects.

show{Boolean} Popup shows or not.  Default is true.
id{String} Unique identifier.  Default is null, the system assigns Id to each popup.
displayClass{String} CSS class name.  Default is “single-search”
size{ALKMaps.Size} Popup size.  Default is 200 * 50.
offset{ALKMaps.Pixel} Popup offset.  Default is (0, -13).
closeBox{Boolean} Having a close box or not.  Default is false.
closeBoxCallback{Function} Function to be called on closeBox click.  Default is null.
exclusive{Boolean} If true, closes all other popups first.  Default is true.

displaySystem

{String} Show distance in KM or Miles.  Accepts metric and english.  Default is metric.

Functions

destroy

destroy: function()

Destroy control.

activate

activate: function()

Activates the control.

Returns

{Boolean} The control was effectively activated.

deactivate

deactivate: function()

Deactivates the control.

Returns

{Boolean} The control was effectively deactivated.

setMap

setMap: function(map)

Sets map and the geocoding layer to the map.

Parameters

map{ALKMaps.Map}

draw

draw: function()

Draws the control.

createResultElement

createResultElement: function(responseItem)

Construct HTML LI item.  The item can raise locationenter, resultslistescape, locationclick, locationblur, locationfocus events.

Example

<li>
    <a href="#" tabindex="0">response item
         <div class="results-icon">
             <img src='' />
         </div>
         <div>
             <div>
                 <span></span>
             </div>
             <div>
                 <span></span>
             </div>
             <div>
                 <span></span>
             </div>
         </div>
    </a>
</li>

setSearchOption

setSearchOption: function(key,
value)

Updates search option.

Parameters

key{String} Key for the property.
value{String|Number|Function} It depends on the key.

searchCompleted

searchCompleted: function(resp)

Default method for handling successful search.  Client can overwrite this method by supplies a callback method in searchOption object.  This method also raised searchcompleted event.

searchFailed

searchFailed: function(resp)

Default method for handling failed search.  It shows a very simple message in the alert.  Strongly recommend client to supply a custom method in searchOption to overwrite this one.

Instances of ALKMaps.Layer.VectorMarkers are used to render vector marker from a variety of sources.
destroy: function()
Destroy control.
activate: function()
Activates the control.
deactivate: function()
Deactivates the control.
setMap: function(map)
Sets map and the geocoding layer to the map.
draw: function()
Draws the control.
createResultElement: function(responseItem)
Construct HTML LI item.
setSearchOption: function(key,
value)
Updates search option.
searchCompleted: function(resp)
Default method for handling successful search.
searchFailed: function(resp)
Default method for handling failed search.
Controls affect the display or behavior of the map.
This class represents a longitude and latitude pair
Instances of this class represent a width/height pair
This class represents a screen coordinate, in x and y coordinates
Instances of ALKMaps.Map are interactive maps embedded in a web page.
Close