Skip to content

Commit

Permalink
fix max zoom default
Browse files Browse the repository at this point in the history
* added a todo for max zoom customization
  • Loading branch information
MV88 committed Jul 11, 2019
1 parent cf14c71 commit 95f2626
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions web/client/components/map/openlayers/Map.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -527,13 +527,12 @@ class OpenlayersMap extends React.Component {
// if EPSG:4326 with max extent (-180, -90, 180, 90) bounds are 0,0,0,0. In this case zoom to max extent
// TODO: improve this to manage all degenerated bounding boxes.
if (bounds && bounds[0] === bounds[2] && bounds[1] === bounds[3] &&
// the following is needed to avoid to use projection extent when extent is generated from a point
crs === "EPSG:4326" && isArray(extent) && extent[0] === -180 && extent[1] === -90) {
bounds = this.map.getView().getProjection().getExtent();
}
let maxZoom = zoomLevel;
if (bounds && bounds[0] === bounds[2] && bounds[1] === bounds[3] && isNil(maxZoom)) {
maxZoom = 20; // is enough for points
maxZoom = 21; // TODO: allow to this maxZoom to be customizable
}
this.map.getView().fit(bounds, {
padding: padding && [padding.top || 0, padding.right || 0, padding.bottom || 0, padding.left || 0],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ describe('OpenlayersMap', () => {
expect(spy.calls[1].arguments[0].x).toBeLessThan(2);
expect(spy.calls[1].arguments[0].y).toBeLessThan(2);
// Bbox should not be max.
expect(spy.calls[1].arguments[1]).toBe(20);
expect(spy.calls[1].arguments[1]).toBe(21);
expect(spy.calls[1].arguments[2].bounds.maxx).toBeGreaterThan(111319);
expect(spy.calls[1].arguments[2].bounds.maxy).toBeGreaterThan(111325);
expect(spy.calls[1].arguments[2].bounds.minx).toBeLessThan(111320);
Expand Down

0 comments on commit 95f2626

Please sign in to comment.