@@ -568,11 +568,13 @@ MapboxGeocoder.prototype = {
568568
569569 _fly : function ( selected ) {
570570 var flyOptions ;
571- const { context, short_code } = selected . properties ;
572- const countryCode = this . options . version === 'v6' ?
573- context && context . country && context . country . country_code . toLowerCase ( ) :
574- short_code ;
575- if ( selected . properties && exceptions [ countryCode ] ) {
571+ let exceptionCode ;
572+ if ( this . options . version === 'v6' && selected . properties . feature_type === 'country' ) {
573+ exceptionCode = selected . properties . context . country . country_code . toLowerCase ( ) ;
574+ } else if ( this . options . version === 'v5' ) {
575+ exceptionCode = selected . properties && selected . properties . short_code ;
576+ }
577+ if ( selected . properties && exceptions [ exceptionCode ] ) {
576578 // Certain geocoder search results return (and therefore zoom to fit)
577579 // an unexpectedly large bounding box: for example, both Russia and the
578580 // USA span both sides of -180/180, or France includes the island of
@@ -581,7 +583,7 @@ MapboxGeocoder.prototype = {
581583 // short-term solution; this may be amended as necessary.
582584 flyOptions = extend ( { } , this . options . flyTo ) ;
583585 if ( this . _map ) {
584- this . _map . fitBounds ( exceptions [ countryCode ] . bbox , flyOptions ) ;
586+ this . _map . fitBounds ( exceptions [ exceptionCode ] . bbox , flyOptions ) ;
585587 }
586588 } else if ( selected . bbox ) {
587589 var bbox = selected . bbox ;
@@ -899,7 +901,9 @@ MapboxGeocoder.prototype = {
899901 if ( ! results . features . length ) return ;
900902 var result = results . features [ 0 ] ;
901903 this . _typeahead . selected = result ;
902- this . _inputEl . value = this . options . version === 'v6' ? result . properties . name : result . place_name ;
904+ this . _inputEl . value = this . options . version === 'v6' ?
905+ ( result . properties . name + ( result . properties . place_formatted ? `, ${ result . properties . place_formatted } ` : "" ) ) :
906+ result . place_name ;
903907 this . _onChange ( ) ;
904908 } ,
905909
0 commit comments