Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Respect initialCenter option when initialCameraFit is used. #1721

Closed
kj415j45 opened this issue Nov 7, 2023 · 3 comments
Closed
Labels
feature This issue requests a new feature invalid This bug could not be reproduced or does not exist, or is very low quality

Comments

@kj415j45
Copy link

kj415j45 commented Nov 7, 2023

What do you want implemented?

The MapOptions should respect initialCenter option to init the user's camera when it does inside the initialCameraFit's bounds. If it is not, it's safe and should init the camera with the bounds' center.

What other alternatives are available?

Currently, we are planning to move the initialCameraFit to TileLayer.tileBounds. This should fix the issue but we may have to repeat it when we have more layers, which sounds like a bad smell. So we are looking for a solution in upstream.

Also, we noticed that there's bounds option may solve it too, but it is a deprecated option.

Can you provide any other information?

Before v6 (#1551), we used center to init the user's camera position, as well as nePanBoundary and swPanBoundary to constrain the user's camera to avoid invalid position selection.

MapOptions(
  center: initLocation,
  maxZoom: 18.48,
  interactiveFlags: InteractiveFlag.all & ~InteractiveFlag.rotate,
  nePanBoundary: bounds.northEast,
  swPanBoundary: bounds.southWest,
),

Now, it uses initialCameraFit to constrain the camera, but the initialCenter would be invalid as document mentioned.

MapOptions(
  backgroundColor: Colors.transparent,
  initialCenter: initLocation, // override by initialCameraFit.
  maxZoom: 18.48,
  interactionOptions: const InteractionOptions(
    flags: InteractiveFlag.all & ~InteractiveFlag.rotate,
  ),
  initialCameraFit: CameraFit.insideBounds(bounds: bounds),
)

Severity

Annoying: Currently have to use workarounds

@kj415j45 kj415j45 added feature This issue requests a new feature P: 3 (low) (Default priority for feature requests) labels Nov 7, 2023
@JaffaKetchup
Copy link
Member

Hi @kj415j45,
I think you're looking for cameraConstraint, not initialCameraFit?

@kj415j45
Copy link
Author

kj415j45 commented Nov 7, 2023

@JaffaKetchup, it looks like what I'm looking for. I may be mislead by the bounds's deprecated info:

'bounds' is deprecated and shouldn't be used. Prefer initialCameraFit instead. This option is now part of initalCameraFit. This option is deprecated since v6.

It's a bit confusing. Shall we update the document? With cameraConstraint, why we still need the initialCameraFit to configure the initial fence?

@JaffaKetchup
Copy link
Member

cameraConstraint is permanent and prevents the camera from going outside the appropriate area, whereas initialCameraFit just positions the camera when the map is first built, instead of using initialCenter and initialZoom. They are two very different things. cameraConstraint used to be maxBounds, and initialCameraFit was previously bounds.

Closing for now, hopefully its all resolved!

@JaffaKetchup JaffaKetchup closed this as not planned Won't fix, can't repro, duplicate, stale Nov 7, 2023
@JaffaKetchup JaffaKetchup added invalid This bug could not be reproduced or does not exist, or is very low quality and removed P: 3 (low) (Default priority for feature requests) labels Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature This issue requests a new feature invalid This bug could not be reproduced or does not exist, or is very low quality
Projects
None yet
Development

No branches or pull requests

2 participants