// SEARCH ///////////////////////////////////////////////////////// /* you can implement your own result provider by listing to the search hook: addHook('search', function(query) {}); `query` is an object with the following members: - `term` is the term for which the user has searched - `confirmed` is a boolean indicating if the user has pressed enter after searching. You should not search online or heavy processing unless the user has confirmed the search term - `addResult(result)` can be called to add a result to the query. `result` may have the following members (`title` is required, as well as one of `position` and `bounds`): - `title`: the label for this result - `description`: secondary information for this result - `position`: a L.LatLng object describing the position of this result - `bounds`: a L.LatLngBounds object describing the bounds of this result - `layer`: a ILayer to be added to the map when the user selects this search result. Will be generated if not set. Set to `null` to prevent the result from being added to the map. - `icon`: a URL to a icon to display in the result list. Should be 12x12. - `onSelected(result, event)`: a handler to be called when the result is selected. May return `true` to prevent the map from being repositioned. You may reposition the map yourself or do other work. - `onRemove(result)`: a handler to be called when the result is removed from the map (because another result has been selected or the search was cancelled by the user). */ window.search = { lastSearch: null, }; window.search.Query = function(term, confirmed) { this.term = term; this.confirmed = confirmed; this.init(); }; window.search.Query.prototype.init = function() { this.results = []; this.container = $('
').addClass('searchquery'); this.header = $('

') .text(this.confirmed ? this.term : ((this.term.length > 16 ? this.term.substr(0,8) + '…' + this.term.substr(this.term.length-8,8) : this.term) + ' (Return to load more)')) .appendTo(this.container); this.list = $('