Opened 2 years ago

Closed 2 years ago

#33637 closed Cleanup/optimization (fixed)

Regression in feature zoom for MapWidget

Reported by: Claude Paroz Owned by: Claude Paroz
Component: GIS Version: 4.0
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When I rewrote MapWidget for OpenLayers 3 in [2ebfda38e], the code to autozoom to the initial feature (if present) was changed from:

this.map.zoomToExtent(feat.geometry.getBounds());
if (this.options.geom_name === 'Point') {
    this.map.zoomTo(this.options.point_zoom);
}

to:

this.map.getView().fit(extent, this.map.getSize(), {maxZoom: this.options.default_zoom});

As a result, the zoom is often the default_zoom, which is mostly not adequate at all (not enough zoom). If we simply remove the maxZoom, the zoom is too high for points (hence the point_zoom in the initial version). I think instead of maxZoom, a minResolution (see https://openlayers.org/en/latest/apidoc/module-ol_View-View.html#fit) would be more appropriate.

We would probably need to reintroduce some point_zoom variable, as providing a hard-coded value is not an option.

Change History (4)

comment:1 by Mariusz Felisiak, 2 years ago

Triage Stage: UnreviewedAccepted
Type: BugCleanup/optimization

Using minResolution sounds reasonable.

comment:2 by Claude Paroz, 2 years ago

Has patch: set

PR

I finally opted for a hard-coded value, as IMO a resolution of 1 should be accurate for most (all?) layer types.

comment:3 by Mariusz Felisiak, 2 years ago

Owner: changed from nobody to Claude Paroz
Status: newassigned

comment:4 by GitHub <noreply@…>, 2 years ago

Resolution: fixed
Status: assignedclosed

In 08f30d1b:

Fixed #33637 -- Improved initial zoom level in MapWidget.

Note: See TracTickets for help on using tickets.
Back to Top