Skip to content

Commit 63ec2e7

Browse files
remove unsupported keys
1 parent 7612087 commit 63ec2e7

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

debug/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ var geocoder = new MapboxGeocoder({
7575
accessToken: mapboxgl.accessToken,
7676
trackProximity: true,
7777
enableGeolocation: true,
78-
useGeocoderV6: true,
7978
localGeocoder: function(query) {
8079
return coordinatesGeocoder(query);
8180
},
@@ -97,6 +96,12 @@ var geocoder = new MapboxGeocoder({
9796
countries: 'US',
9897
postcode: 'postcode',
9998
locality: 'locality',
99+
100+
version: 'v6',
101+
types: "address",
102+
mode: 'mapbox.places-permanent',
103+
reverseGeocode: true,
104+
flipCoordinates: true,
100105
permanent: true
101106
});
102107

lib/index.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ MapboxGeocoder.prototype = {
633633
'countries',
634634
'types',
635635
'language',
636-
'mode', // permanent so for actual for both v5 and v6
636+
'mode',
637637
'autocomplete',
638638
'worldview'
639639
];
@@ -686,13 +686,6 @@ MapboxGeocoder.prototype = {
686686
this.options.version === 'v6' ? { longitude: coords[0], latitude: coords[1]} : { query: coords },
687687
{limit: 1 }
688688
);
689-
690-
// Remove config options not supported by the reverseGeocoder
691-
['proximity', 'autocomplete', 'fuzzyMatch', 'bbox'].forEach(function(key) {
692-
if (key in config) {
693-
delete config[key]
694-
}
695-
});
696689
} break;
697690
case GEOCODE_REQUEST_TYPE.FORWARD: {
698691
// Ensure that any reverse geocoding looking request is cleaned up
@@ -710,6 +703,18 @@ MapboxGeocoder.prototype = {
710703
} break;
711704
}
712705

706+
// Remove config options not supported by the reverseGeocoder and v5 keys if v6 mode chosen
707+
const unsupportedKeys = [
708+
...(requestType === GEOCODE_REQUEST_TYPE.REVERSE ? ['proximity', 'autocomplete', 'fuzzyMatch', 'bbox'] : []),
709+
...(this.options.version === 'v6' ? v5Keys : [])
710+
];
711+
712+
unsupportedKeys.forEach(function(key) {
713+
if (key in config) {
714+
delete config[key]
715+
}
716+
});
717+
713718
return config;
714719
},
715720

0 commit comments

Comments
 (0)