File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -191,6 +191,7 @@ MapboxGeocoder.prototype = {
191191 var keys = [
192192 'bbox' ,
193193 'limit' ,
194+ 'proximity' ,
194195 'countries' ,
195196 'types' ,
196197 'language' ,
@@ -205,6 +206,10 @@ MapboxGeocoder.prototype = {
205206 [ 'countries' , 'types' , 'language' ] . indexOf ( key ) > - 1
206207 ? ( config [ key ] = self . options [ key ] . split ( / [ \s , ] + / ) )
207208 : ( config [ key ] = self . options [ key ] ) ;
209+
210+ if ( key === 'proximity' && self . options [ key ] && self . options [ key ] . longitude && self . options [ key ] . latitude ) {
211+ config [ key ] = [ self . options [ key ] . longitude , self . options [ key ] . latitude ]
212+ }
208213 }
209214 return config ;
210215 } , { } ) ;
Original file line number Diff line number Diff line change @@ -399,5 +399,26 @@ test('geocoder', function(tt) {
399399 t . notOk ( geocoder . getProximity ( ) , 'proximity unset after zooming out' ) ;
400400 } ) ;
401401
402+ tt . test ( 'options.setProximity' , function ( t ) {
403+ t . plan ( 1 ) ;
404+
405+ setup ( { } ) ;
406+
407+ map . setZoom ( 13 ) ;
408+ map . setCenter ( [ - 79.4512 , 43.6568 ] ) ;
409+ geocoder . setProximity ( { longitude : - 79.4512 , latitude : 43.6568 } ) ;
410+
411+ geocoder . query ( 'high' ) ;
412+ geocoder . on (
413+ 'results' ,
414+ once ( function ( e ) {
415+ t . ok (
416+ e . features [ 0 ] . place_name . indexOf ( 'Toronto' ) !== - 1 ,
417+ 'proximity applied in geocoding request'
418+ ) ;
419+ } )
420+ ) ;
421+ } ) ;
422+
402423 tt . end ( ) ;
403424} ) ;
You can’t perform that action at this time.
0 commit comments