Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
offtherailz committed May 18, 2016
1 parent dae781c commit 2f377df
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
13 changes: 13 additions & 0 deletions web/client/reducers/__tests__/map-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,17 @@ describe('Test the map reducer', () => {
expect(state.prop).toBe('prop');
expect(state.projection).toBe('EPSG:4326');
});

it('zoom to extent', () => {
const action = {
type: 'ZOOM_TO_EXTENT',
extent: [10, 44, 12, 46],
crs: "EPSG:4326"
};

var state = mapConfig({}, action);
expect(state.mapStateSource).toBe(undefined);
expect(state.center.x).toBe(11);
expect(state.center.y).toBe(45);
});
});
3 changes: 2 additions & 1 deletion web/client/reducers/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ function mapConfig(state = null, action) {
action.crs, 'EPSG:4326');
return assign({}, state, {
zoom,
center
center,
mapStateSource: action.mapStateSource
});
}
case PAN_TO: {
Expand Down
2 changes: 1 addition & 1 deletion web/client/utils/MapUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ function defaultGetZoomForExtent(extent, mapSize, minZoom, maxZoom, dpi, mapReso
return diff > previous.diff ? previous : {diff: diff, zoom: index};
}, {diff: Number.POSITIVE_INFINITY, zoom: 0});

return Math.max(0, zoom);
return Math.max(0, zoom, Math.min(zoom, maxZoom));
}

/**
Expand Down

0 comments on commit 2f377df

Please sign in to comment.