lib/events.js
function (event, geocoder) {
    var proximity;
    if (!geocoder.options.proximity) proximity = null;
    else proximity = [geocoder.options.proximity.longitude, geocoder.options.proximity.latitude];

    var zoom = (geocoder._map) ? geocoder._map.getZoom() : null;
    var payload = {
      event: event,
      created: +new Date(),
      sessionIdentifier: this.sessionID,
      country: this.countries,
      userAgent: this.userAgent,
      language: this.language,
      bbox: this.bbox,
      types: this.types,
      endpoint: 'mapbox.places',
      // fuzzyMatch: search.fuzzy, //todo  --> add to plugin
      proximity: proximity,
      limit: geocoder.options.limit,
      // routing: search.routing, //todo --> add to plugin
      mapZoom: zoom,
      keyboardLocale: this.locale
    }

    // get the text in the search bar
    if (event === "search.select"){
      payload.queryString = geocoder.inputString;
    }else if (event != "search.select" && geocoder._inputEl){
      payload.queryString = geocoder._inputEl.value;
    }else{
      payload.queryString = geocoder.inputString;
    }
    return payload;
  }
function (event, geocoder) {
    var proximity;
    if (!geocoder.options.proximity) proximity = null;
    else proximity = [geocoder.options.proximity.longitude, geocoder.options.proximity.latitude];

    var zoom = (geocoder._map) ? geocoder._map.getZoom() : null;
    var payload = {
      event: event,
      created: +new Date(),
      sessionIdentifier: this.sessionID,
      country: this.countries,
      userAgent: this.userAgent,
      language: this.language,
      bbox: this.bbox,
      types: this.types,
      endpoint: 'mapbox.places',
      // fuzzyMatch: search.fuzzy, //todo  --> add to plugin
      proximity: proximity,
      limit: geocoder.options.limit,
      // routing: search.routing, //todo --> add to plugin
      mapZoom: zoom,
      keyboardLocale: this.locale
    }

    // get the text in the search bar
    if (event === "search.select"){
      payload.queryString = geocoder.inputString;
    }else if (event != "search.select" && geocoder._inputEl){
      payload.queryString = geocoder._inputEl.value;
    }else{
      payload.queryString = geocoder.inputString;
    }
    return payload;
  }
function ( event , geocoder ) { var proximity ; if ( ! geocoder . options . proximity ) proximity = null ; else proximity = [ geocoder . options . proximity . longitude , geocoder . options . proximity . latitude ] ; var zoom = ( geocoder . _map ) ? geocoder . _map . getZoom ( ) : null ; var payload = { event : event , created : + new Date ( ) , sessionIdentifier : this . sessionID , country : this . countries , userAgent : this . userAgent , language : this . language , bbox : this . bbox , types : this . types , endpoint : 'mapbox.places' , // fuzzyMatch: search.fuzzy, //todo  --> add to plugin proximity : proximity , limit : geocoder . options . limit , // routing: search.routing, //todo --> add to plugin mapZoom : zoom , keyboardLocale : this . locale } // get the text in the search bar if ( event === "search.select" ) { payload . queryString = geocoder . inputString ; } else if ( event != "search.select" && geocoder . _inputEl ) { payload . queryString = geocoder . _inputEl . value ; } else { payload . queryString = geocoder . inputString ; } return payload ; }
Get the event payload to send to the events service
Most payload properties are shared across all events
@private
@param {String} event the name of the event to send to the events service. Valid options are 'search.start', 'search.select', 'search.feedback'.
@param {Object} geocoder a mapbox-gl-geocoder instance
@returns {Object} an event payload
Get the event payload to send to the events service Most payload properties are shared across all events