Skip to content

Add option to snap/spring to nearest integer zoom level (if close) #2053

@corepuncher

Description

@corepuncher

What do you want implemented?

Say the user stops zooming and they are VERY CLOSE to a higher resolution set of tiles. You can set a small threshold say within 0.10 of the clamped zoom level, and if they are within that small range after they are done zooming, "snap" to the higher zoom. It could default to off but allow use to enable and set the threshold value.

For example, I do this in my onPositionChanged:

                stopOpcAutoZoomTimer();
                          if (zoomingMap) {
                            _opcAutoZoomTimer = Timer(Duration(milliseconds: 64), () async {
                              double maxZoomLevel = 10;
                              // Snaps to nearby higher-res zoom level if close enough
                              for (double level = 4; level <= maxZoomLevel; level++) {
                                double threshold = level + 0.5;
                                if (mapState.zoom > threshold - 0.1 && mapState.zoom < threshold) {
                                  stopPositionChangedTimer();
                                  mapState.move(
                                      LatLng(centerPosition.latitude, centerPosition.longitude), threshold);
                                  break;
                                }
                              }
                            });
                          }

Not sure what optimal timer duration would be, but you could leave it up to the user.

What other alternatives are available?

No response

Can you provide any other information?

No response

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions