@@ -32,6 +32,36 @@ function getFooterNode() {
3232 return div ;
3333}
3434
35+ function getItemValue ( item ) {
36+ return item . place_name
37+ }
38+
39+ function render ( item ) {
40+ var placeName = item . place_name . split ( ',' ) ;
41+ return '<div class="mapboxgl-ctrl-geocoder--suggestion"><div class="mapboxgl-ctrl-geocoder--suggestion-title">' + placeName [ 0 ] + '</div><div class="mapboxgl-ctrl-geocoder--suggestion-address">' + placeName . splice ( 1 , placeName . length ) . join ( ',' ) + '</div></div>' ;
42+ }
43+
44+ function getItemValueV6 ( item ) {
45+ const { name, place_formatted } = item . properties ;
46+ return name + ( place_formatted ? `, ${ place_formatted } ` : "" ) ;
47+ }
48+
49+ function renderV6 ( item ) {
50+ const { name, place_formatted } = item . properties ;
51+ return `<div class="mapboxgl-ctrl-geocoder--suggestion">
52+ ${
53+ name
54+ ? `<div class="mapboxgl-ctrl-geocoder--suggestion-title">${ name } </div>`
55+ : ""
56+ }
57+ ${
58+ place_formatted
59+ ? `<div class="mapboxgl-ctrl-geocoder--suggestion-address">${ place_formatted } </div>`
60+ : ""
61+ }
62+ </div>` ;
63+ }
64+
3565/**
3666 * A geocoder component using the [Mapbox Geocoding API](https://docs.mapbox.com/api/search/#geocoding)
3767 * @class MapboxGeocoder
@@ -85,36 +115,6 @@ function getFooterNode() {
85115 *
86116 */
87117
88- function getItemValue ( item ) {
89- return item . place_name
90- }
91-
92- function render ( item ) {
93- var placeName = item . place_name . split ( ',' ) ;
94- return '<div class="mapboxgl-ctrl-geocoder--suggestion"><div class="mapboxgl-ctrl-geocoder--suggestion-title">' + placeName [ 0 ] + '</div><div class="mapboxgl-ctrl-geocoder--suggestion-address">' + placeName . splice ( 1 , placeName . length ) . join ( ',' ) + '</div></div>' ;
95- }
96-
97- function getItemValueV6 ( item ) {
98- const { name, place_formatted } = item . properties ;
99- return name + ( place_formatted ? `, ${ place_formatted } ` : "" ) ;
100- }
101-
102- function renderV6 ( item ) {
103- const { name, place_formatted } = item . properties ;
104- return `<div class="mapboxgl-ctrl-geocoder--suggestion">
105- ${
106- name
107- ? `<div class="mapboxgl-ctrl-geocoder--suggestion-title">${ name } </div>`
108- : ""
109- }
110- ${
111- place_formatted
112- ? `<div class="mapboxgl-ctrl-geocoder--suggestion-address">${ place_formatted } </div>`
113- : ""
114- }
115- </div>` ;
116- }
117-
118118function MapboxGeocoder ( options ) {
119119 this . _eventEmitter = new EventEmitter ( ) ;
120120 this . options = extend ( { } , this . options , {
@@ -695,14 +695,15 @@ MapboxGeocoder.prototype = {
695695 if ( reverseGeocodeCoordRgx . test ( trimmedSearch ) ) {
696696 search = search . replace ( / , / g, ' ' ) ;
697697 }
698- if ( this . options . version === 'v6' && config . mode ) {
699- config . permanent = config . mode === 'mapbox.places-permanent' ;
700- delete config . mode ;
701- }
702698 config = extend ( config , { query : search } ) ;
703699 } break ;
704700 }
705701
702+ if ( this . options . version === 'v6' && config . mode ) {
703+ config . permanent = config . mode === 'mapbox.places-permanent' ;
704+ delete config . mode ;
705+ }
706+
706707 // Remove config options not supported by the reverseGeocoder and v5 keys if v6 mode chosen
707708 const unsupportedKeys = [
708709 ...( requestType === GEOCODE_REQUEST_TYPE . REVERSE ? [ 'proximity' , 'autocomplete' , 'fuzzyMatch' , 'bbox' ] : [ ] ) ,
0 commit comments