AutoComplete
AMap.AutoComplete
Match information based on input keyword prompts, and use POI type and city as input prompt restrictions. Users can retrieve and display through a custom callback function. Construct an input prompt plugin object
new AMap.AutoComplete(opts: object)Parameter
opts (object) Input prompt parameters
Demo
AMap.plugin("AMap.AutoComplete", function () {
var autoOptions = {
city: "724010000",
};
var autoComplete = new AMap.AutoComplete(autoOptions);
});Method
setType(type)
Set prompt Poi types, multiple types are separated by '|'. For related Poi types, please download from the 'Related Downloads' section on the website. Currently, only Poi type codes such as '050000' are supported. Default value: all categories
Parameter: type (String) Prompt Poi type
Demo:
autoComplete.setType(“050000”);setCityLimit(citylimit)
Set whether to enforce city restrictions
Parameter: citylimit (boolean) Whether to enforce city restrictions
Demo:
autoComplete.setCityLimit(true);search(keyword, callback)
Provide matching information based on input keywords
Parameter:
keyword (String) Keyword
callback (AutoCompleteSearchCallback) Search result callback
Demo:
//Search based on keywords, where 'keyword' is the search term
autoComplete.search(keyword, function (status, result) {
//When the search is successful, the result is the corresponding matching data
console.log(result);
});Event
select
This event is triggered when a POI information is selected by mouse click or pressing enter
Parameter: event (object) Return Parameters
choose
This event is triggered when selecting POI information with the mouse or the up and down keys on the keyboard
Parameter: event (object) Return Parameters