diff --git a/lib/index.js b/lib/index.js index 8fbc22c..b95c918 100644 --- a/lib/index.js +++ b/lib/index.js @@ -633,7 +633,7 @@ MapboxGeocoder.prototype = { 'countries', 'types', 'language', - 'mode', // permanent so for actual for both v5 and v6 + 'mode', 'autocomplete', 'worldview' ]; @@ -686,13 +686,6 @@ MapboxGeocoder.prototype = { this.options.version === 'v6' ? { longitude: coords[0], latitude: coords[1]} : { query: coords }, {limit: 1 } ); - - // Remove config options not supported by the reverseGeocoder - ['proximity', 'autocomplete', 'fuzzyMatch', 'bbox'].forEach(function(key) { - if (key in config) { - delete config[key] - } - }); } break; case GEOCODE_REQUEST_TYPE.FORWARD: { // Ensure that any reverse geocoding looking request is cleaned up @@ -710,6 +703,18 @@ MapboxGeocoder.prototype = { } break; } + // Remove config options not supported by the reverseGeocoder and v5 keys if v6 mode chosen + const unsupportedKeys = [ + ...(requestType === GEOCODE_REQUEST_TYPE.REVERSE ? ['proximity', 'autocomplete', 'fuzzyMatch', 'bbox'] : []), + ...(this.options.version === 'v6' ? v5Keys : []) + ]; + + unsupportedKeys.forEach(function(key) { + if (key in config) { + delete config[key] + } + }); + return config; },