Skip to content

Unbounded horizontal scroll does not play well with longitude constraints near 180 or -180 #2072

Open

Description

@mbenoukaiss

What is the bug?

Let's say someone wants to have a map constrained to Te Waipounamu, the south island of New Zealand, because why not. Good camera constraints coordinates would be between -38.82;164.37 and -49.49;177.86.

However because the bottom right corner is so close to longitude 180 and because of the way unbounded horizontal scroll is implemented, if you pan with enough speed towards the east, it will reach the constraints and jump you back to the west instead of stopping at the constraint.

I discovered it while trying to understand what causes #2071 precisely

How can we reproduce it?

Create a FlutterMap with the following property set in MapOptions : cameraConstraint: CameraConstraint.contain(bounds: LatLngBounds(const LatLng(-38.82, 164.37), const LatLng(-49.49, 177.86)))

Do you have a potential solution?

No idea yet, don't know how unbounded constraints work

Activity

  1. added
    needs triageThis new bug report needs reproducing and prioritizing
    on Apr 6, 2025
  2. added theissue type on Apr 6, 2025
  3. JaffaKetchup commented on Apr 8, 2025

    @JaffaKetchup
    Member

    Hi @mbenoukaiss, thanks for all the research!

    I'm aware that this could be an issue. Can you also just share your initial camera config? For me, the entire map just turns black if the initial camera is outside of the constraints.

  4. mbenoukaiss commented on Apr 9, 2025

    @mbenoukaiss
    ContributorAuthor

    Can you also just share your initial camera config? For me, the entire map just turns black if the initial camera is outside of the constraints.

    Hi, sorry for the insufficiently detailed snippet, by running the example app on the home route and with the following FlutterMap I manage to reproduce on ios and chrome (got to fling it hard though, harder than on mobile) :

    FlutterMap(
      options: MapOptions(
        minZoom: 0,
        initialZoom: 8,
        maxZoom: 17,
        initialCenter: const LatLng(-44.28, 170.54),
        cameraConstraint: CameraConstraint.contain(
          bounds: LatLngBounds(
            const LatLng(-38.82, 164.37),
            const LatLng(-49.49, 177.86),
          ),
        ),
      ),
      children: [
        openStreetMapTileLayer,
        RichAttributionWidget(
          popupInitialDisplayDuration: const Duration(seconds: 5),
          animationConfig: const ScaleRAWA(),
          showFlutterMapAttribution: false,
          attributions: [
            TextSourceAttribution(
              'OpenStreetMap contributors',
              onTap: () async => launchUrl(
                Uri.parse('https://openstreetmap.org/copyright'),
              ),
            ),
            const TextSourceAttribution(
              'This attribution is the same throughout this app, except '
              'where otherwise specified',
              prependCopyright: false,
            ),
          ],
        ),
      ],
    ),
  5. removed
    needs triageThis new bug report needs reproducing and prioritizing
    on Jul 1, 2026
  6. JaffaKetchup commented on Jul 1, 2026

    @JaffaKetchup
    Member

    This feels similar to #2022.

  7. monsieurtanuki commented on Jul 2, 2026

    @monsieurtanuki
    Contributor

    @JaffaKetchup Would that mean that we should definitely support that "world number" feature?

  8. JaffaKetchup commented on Jul 2, 2026

    @JaffaKetchup
    Member

    @monsieurtanuki Yeah, we need to add world numbers to LatLngBounds, as well as thinking about it for paths, as discussed in #2206 (comment). Not sure if you've seen #2205 - it's sort of related (allows across the antimeridian, but doesn't use world numbers)?

    Although I don't think that is related to this issue, or directly related to #2022? Unless you're thinking of something I'm not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    Priority

    Medium

    Effort

    High

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions