Skip to content

Commit

Permalink
fix TypeError thrown when Map.querySourceFeatures doesn't include a p…
Browse files Browse the repository at this point in the history
…arameters option
  • Loading branch information
andrewharvey committed Nov 4, 2016
1 parent 358cabe commit d43ecb5
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
2 changes: 1 addition & 1 deletion js/source/tile.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class Tile {

if (!layer) return;

const filter = featureFilter(params.filter);
const filter = featureFilter(params && params.filter);
const coord = { z: this.coord.z, x: this.coord.x, y: this.coord.y };

for (let i = 0; i < layer.length; i++) {
Expand Down
45 changes: 45 additions & 0 deletions test/js/ui/map.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,7 @@ test('Map', (t) => {

t.test('if only "geometry" provided', (t) => {
createMap({}, (err, map) => {

t.error(err);
t.spy(map.style, 'queryRenderedFeatures');

Expand Down Expand Up @@ -646,6 +647,50 @@ test('Map', (t) => {
t.end();
});

t.test('#querySourceFeatures', (t) => {
t.test('if no parameters provided', (t) => {
const map = createMap({
style: {
"version": 8,
"sources": {
"geojson": {
"type": "geojson",
"data": {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [0, 0]
},
"properties": {}
}
]
}
}
},
layers: [
{
"id": "circle",
"source": "geojson",
"type": "circle"
}
]
}
});

map.once('load', () => {
const output = map.querySourceFeatures('geojson');

t.equal(output.length, 1);

t.end();
});
});
t.end();
});

t.test('#setLayoutProperty', (t) => {
t.test('sets property', (t) => {
const map = createMap({
Expand Down

0 comments on commit d43ecb5

Please sign in to comment.