lib/events.js
function(selected, geocoder){
    var resultIndex = this.getSelectedIndex(selected, geocoder);
    var payload = this.getEventPayload('search.select', geocoder);
    payload.resultIndex = resultIndex;
    payload.resultPlaceName  = selected.place_name;
    payload.resultId = selected.id;
    if ((resultIndex === this.lastSentIndex && payload.queryString === this.lastSentInput) || resultIndex == -1) {
      // don't log duplicate events if the user re-selected the same feature on the same search
      return;
    }
    this.lastSentIndex = resultIndex;
    this.lastSentInput = payload.queryString;
    if (!payload.queryString) return; // will be rejected
    return this.push(payload)
  }
function(selected, geocoder){
    var resultIndex = this.getSelectedIndex(selected, geocoder);
    var payload = this.getEventPayload('search.select', geocoder);
    payload.resultIndex = resultIndex;
    payload.resultPlaceName  = selected.place_name;
    payload.resultId = selected.id;
    if ((resultIndex === this.lastSentIndex && payload.queryString === this.lastSentInput) || resultIndex == -1) {
      // don't log duplicate events if the user re-selected the same feature on the same search
      return;
    }
    this.lastSentIndex = resultIndex;
    this.lastSentInput = payload.queryString;
    if (!payload.queryString) return; // will be rejected
    return this.push(payload)
  }
function ( selected , geocoder ) { var resultIndex = this . getSelectedIndex ( selected , geocoder ) ; var payload = this . getEventPayload ( 'search.select' , geocoder ) ; payload . resultIndex = resultIndex ; payload . resultPlaceName = selected . place_name ; payload . resultId = selected . id ; if ( ( resultIndex === this . lastSentIndex && payload . queryString === this . lastSentInput ) || resultIndex == - 1 ) { // don't log duplicate events if the user re-selected the same feature on the same search return ; } this . lastSentIndex = resultIndex ; this . lastSentInput = payload . queryString ; if ( ! payload . queryString ) return ; // will be rejected return this . push ( payload ) }
Send a search.select event to the mapbox events service
This event marks the array index of the item selected by the user out of the array of possible options
@private
@param {Object} selected the geojson feature selected by the user
@param {Object} geocoder a mapbox-gl-geocoder instance
@returns {Promise}
Send a search . select event to the mapbox events service This event marks the array index of the item selected by the user out of the array of possible options