Skip to content

Commit 3dc0744

Browse files
handle bbox property
1 parent d5b02b1 commit 3dc0744

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -568,12 +568,15 @@ MapboxGeocoder.prototype = {
568568

569569
_fly: function(selected) {
570570
var flyOptions;
571+
const bbox = this.options.version === 'v6' ? selected.properties.bbox : selected.bbox;
572+
571573
let exceptionCode;
572574
if (this.options.version === 'v6' && selected.properties.feature_type === 'country') {
573575
exceptionCode = selected.properties.context.country.country_code.toLowerCase();
574576
} else if (this.options.version === 'v5') {
575577
exceptionCode = selected.properties && selected.properties.short_code;
576578
}
579+
577580
if (selected.properties && exceptions[exceptionCode]) {
578581
// Certain geocoder search results return (and therefore zoom to fit)
579582
// an unexpectedly large bounding box: for example, both Russia and the
@@ -585,8 +588,7 @@ MapboxGeocoder.prototype = {
585588
if (this._map){
586589
this._map.fitBounds(exceptions[exceptionCode].bbox, flyOptions);
587590
}
588-
} else if (selected.bbox) {
589-
var bbox = selected.bbox;
591+
} else if (bbox) {
590592
flyOptions = extend({}, this.options.flyTo);
591593
if (this._map){
592594
this._map.fitBounds([[bbox[0], bbox[1]], [bbox[2], bbox[3]]], flyOptions);

0 commit comments

Comments
 (0)