1- import MapboxGeocoder from " @mapbox/mapbox-gl-geocoder" ;
2- import { $helpers } from " vue-mapbox" ;
1+ import MapboxGeocoder from ' @mapbox/mapbox-gl-geocoder' ;
2+ import { $helpers } from ' vue-mapbox' ;
33
44const geocoderEvents = {
5- clear : " clear" ,
6- loading : " loading" ,
7- results : " results" ,
8- result : " result" ,
9- error : " error"
5+ clear : ' clear' ,
6+ loading : ' loading' ,
7+ results : ' results' ,
8+ result : ' result' ,
9+ error : ' error' ,
1010} ;
1111
1212export default {
13- name : " GeocoderControl" ,
13+ name : ' GeocoderControl' ,
1414 mixins : [ $helpers . asControl ] ,
1515
16- inject : [ " mapbox" , " map" ] ,
16+ inject : [ ' mapbox' , ' map' ] ,
1717
1818 props : {
1919 // Mapbox-geocoder options
2020 accessToken : {
2121 type : String ,
22- required : true
22+ required : true ,
2323 } ,
2424 zoom : {
2525 type : Number ,
26- default : 16
26+ default : 16 ,
2727 } ,
2828 flyTo : {
2929 type : Boolean ,
30- default : true
30+ default : true ,
3131 } ,
3232 placeholder : {
3333 type : String ,
34- default : " Search"
34+ default : ' Search' ,
3535 } ,
3636 proximity : {
3737 type : Object ,
38- default : null
38+ default : null ,
3939 } ,
4040 trackProximity : {
4141 type : Boolean ,
42- default : false
42+ default : false ,
4343 } ,
4444 bbox : {
4545 type : Array ,
46- default : null
46+ default : null ,
4747 } ,
4848 types : {
4949 type : String ,
50- default : null
50+ default : null ,
5151 } ,
5252 country : {
5353 type : String ,
54- default : null
54+ default : null ,
5555 } ,
5656 minLength : {
5757 type : Number ,
58- default : 2
58+ default : 2 ,
5959 } ,
6060 limit : {
6161 type : Number ,
62- default : 5
62+ default : 5 ,
6363 } ,
6464 language : {
6565 type : String ,
66- default : null
66+ default : null ,
6767 } ,
6868 filter : {
6969 type : Function ,
70- default : null
70+ default : null ,
7171 } ,
7272 localGeocoder : {
7373 type : Function ,
74- default : null
74+ default : null ,
7575 } ,
7676 // Component options
7777 input : {
7878 type : String ,
79- default : null
80- }
79+ default : null ,
80+ } ,
8181 } ,
8282
8383 data ( ) {
8484 return {
85- initial : true
85+ initial : true ,
8686 } ;
8787 } ,
8888
@@ -93,13 +93,13 @@ export default {
9393 this . control . setInput ( next ) ;
9494 }
9595 } ,
96- immediate : true
96+ immediate : true ,
9797 } ,
9898 proximity ( next , prev ) {
9999 if ( this . control && next !== prev ) {
100100 this . control . setProximity ( next ) ;
101101 }
102- }
102+ } ,
103103 } ,
104104
105105 created ( ) {
@@ -108,13 +108,13 @@ export default {
108108 this . mapbox . accessToken = this . accessToken ;
109109 }
110110 this . control = new MapboxGeocoder ( this . $props ) ;
111- this . control . on ( " results" , this . $_updateInput ) ;
111+ this . control . on ( ' results' , this . $_updateInput ) ;
112112
113113 this . $_deferredMount ( ) ;
114114 } ,
115115
116116 beforeDestroy ( ) {
117- this . control . off ( " results" , this . $_updateInput ) ;
117+ this . control . off ( ' results' , this . $_updateInput ) ;
118118 } ,
119119
120120 methods : {
@@ -123,14 +123,14 @@ export default {
123123 if ( this . input ) {
124124 this . control . setInput ( this . input ) ;
125125 }
126- this . $_emitEvent ( " added" , { geocoder : this . control } ) ;
126+ this . $_emitEvent ( ' added' , { geocoder : this . control } ) ;
127127 this . $_bindSelfEvents ( Object . keys ( geocoderEvents ) ) ;
128128 this . initial = false ;
129129 } ,
130130
131131 $_bindSelfEvents ( events ) {
132132 const vm = this ;
133- Object . keys ( this . $listeners ) . forEach ( eventName => {
133+ Object . keys ( this . $listeners ) . forEach ( ( eventName ) => {
134134 if ( events . includes ( eventName ) ) {
135135 this . control . on ( eventName , vm . $_emitControlEvent . bind ( vm , eventName ) ) ;
136136 }
@@ -143,17 +143,17 @@ export default {
143143
144144 $_updateInput ( results ) {
145145 if ( ! this . initial ) {
146- const input = results . query ? results . query . join ( "" ) : "" ;
147- this . $emit ( " update:input" , input ) ;
146+ const input = results . query ? results . query . join ( '' ) : '' ;
147+ this . $emit ( ' update:input' , input ) ;
148148 }
149149 } ,
150150
151151 query ( query ) {
152152 if ( this . control ) {
153- this . $emit ( " update:input" , query ) ;
153+ this . $emit ( ' update:input' , query ) ;
154154 return this . contol . query ( query ) ;
155155 }
156156 return null ;
157- }
158- }
157+ } ,
158+ } ,
159159} ;
0 commit comments