lib/events.js
function(selected, geocoder){
    if (!geocoder._typeahead) return;
    var results = geocoder._typeahead.data;
    var selectedID = selected.id;
    var resultIDs = results.map(function (feature) {
      return feature.id;
    });
    var selectedIdx = resultIDs.indexOf(selectedID);
    return selectedIdx;
  }
function(selected, geocoder){
    if (!geocoder._typeahead) return;
    var results = geocoder._typeahead.data;
    var selectedID = selected.id;
    var resultIDs = results.map(function (feature) {
      return feature.id;
    });
    var selectedIdx = resultIDs.indexOf(selectedID);
    return selectedIdx;
  }
function ( selected , geocoder ) { if ( ! geocoder . _typeahead ) return ; var results = geocoder . _typeahead . data ; var selectedID = selected . id ; var resultIDs = results . map ( function ( feature ) { return feature . id ; } ) ; var selectedIdx = resultIDs . indexOf ( selectedID ) ; return selectedIdx ; }
Get the 0-based numeric index of the item that the user selected out of the list of options
@private
@param {Object} selected the geojson feature selected by the user
@param {Object} geocoder a Mapbox-GL-Geocoder instance
@returns {Number} the index of the selected result
Get the 0 - based numeric index of the item that the user selected out of the list of options