Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set trackProximity to true by default #202

Merged
merged 2 commits into from
Mar 14, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var geocoderService;
* a geographical point given as an object with latitude and longitude
* properties. Search results closer to this point will be given
* higher priority.
* @param {Boolean} [options.trackProximity=false] If true, the geocoder proximity will automatically update based on the map view.
* @param {Boolean} [options.trackProximity=true] If true, the geocoder proximity will automatically update based on the map view.
* @param {Array} [options.bbox] a bounding box argument: this is
* a bounding box given as an array in the format [minX, minY, maxX, maxY].
* Search results will be limited to the bounding box.
Expand Down Expand Up @@ -59,7 +59,7 @@ MapboxGeocoder.prototype = {
placeholder: 'Search',
zoom: 16,
flyTo: true,
trackProximity: false,
trackProximity: true,
minLength: 2,
reverseGeocode: false,
limit: 5,
Expand Down
11 changes: 11 additions & 0 deletions test/test.geocoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ test('geocoder', function(tt) {
t.ok(geocoder.fresh, 'geocoder is initialized with fresh status to enable turnstile event');
t.equals(geocoder.inputString, '', 'geocoder is initialized with an input string for keeping track of state');
t.ok(geocoder.eventManager instanceof mapboxEvents, 'the geocoder has a mapbox event manager');
t.true(geocoder.options.trackProximity, 'sets trackProximity to true by default');
t.end();
});

Expand Down Expand Up @@ -410,6 +411,16 @@ test('geocoder', function(tt) {
t.notOk(geocoder.getProximity(), 'proximity unset after zooming out');
});

tt.test('options.trackProximity=false', function(t) {
t.plan(2);

setup({
trackProximity: false
});
t.false(geocoder.options.trackProximity, 'track proximity is set to false');
t.notOk(geocoder.getProximity(), 'proximity is not available when trackProximity is set to false');
});

tt.test('options.setProximity', function(t) {
t.plan(1);

Expand Down