1
0
forked from MTSR/mapserver
mapserver/server/static/js/search/SearchService.js
2019-04-15 07:54:11 +02:00

40 lines
771 B
JavaScript

/* exported SearchService */
/* globals SearchStore: true */
var SearchService = {
search: function(q){
SearchStore.query = q;
this.fetchData();
},
fetchData: debounce(function(){
SearchStore.result = [];
if (!SearchStore.query){
return;
}
api.getMapObjects({
pos1: { x:-2048, y:-2048, z:-2048 },
pos2: { x:2048, y:2048, z:2048 },
type: "shop",
attributelike: {
key: "out_item",
value: "%" + SearchStore.query + "%"
}
})
.then(function(result){
SearchStore.result = result;
//console.log(result); //XXX
});
}, 400),
clear: function(){
SearchStore.query = "";
SearchStore.result = [];
}
};