Skip to content

Conversation

@evil159
Copy link
Contributor

@evil159 evil159 commented Nov 15, 2024

What does this pull request do?

This pull request introduces viewport support to the MapWidget, allowing developers to control the camera’s initial position and behavior when displaying a map. By specifying a ViewportState subclass in the viewport parameter, developers can center the map on specific locations, follow the user’s position, or display an overview of a geometry.

MapWidget(
  viewport: CameraViewportState(
    center: Point(coordinates: Position(-117.918976, 33.812092)),
    zoom: 15.0,
  ),
);

What is the motivation and context behind this change?

https://mapbox.atlassian.net/browse/MAPSFLT-60

Pull request checklist:

  • Add a changelog entry.
  • Write tests for all new functionality. If tests were not written, please explain why.
  • Add documentation comments for any added or updated public APIs.

@evil159 evil159 requested a review from a team as a code owner November 15, 2024 14:06
@evil159 evil159 requested a review from maios November 15, 2024 14:06
return makeCameraViewportState(camera: options.toCameraOptions())
default:
throw ViewportInternalError(
code: "Could not create viewport state ouf of options \(stateStorage)",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
code: "Could not create viewport state ouf of options \(stateStorage)",
code: "Could not create viewport state out of options \(stateStorage)",

@evil159 evil159 requested a review from pjleonard37 December 2, 2024 13:37
pjleonard37
pjleonard37 previously approved these changes Dec 2, 2024
Copy link
Contributor

@pjleonard37 pjleonard37 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Excited for this :)

@evil159 evil159 merged commit f25319c into main Dec 2, 2024
6 checks passed
@evil159 evil159 deleted the rl/viewport branch December 2, 2024 16:12
brandon-watkins-avcrm pushed a commit to brandon-watkins-avcrm/mapbox-maps-flutter that referenced this pull request Mar 27, 2025
* Viewport draft

* Simple map example

* format

* more viewport

* declarative viewport draft

* Declarative viewport on iOS and Android

* Fix rebase issues

* Docs, example + bug fix

* add changelog entry

* typo

* Remove unused code

* lint

* lint

* Fix en-/de- coding for CameraViewportState

* Fix exception when converting CameraOptions for CameraViewportState on Android

* Add note about location requirement for FollowPuckViewportState

* Add tests for viewport states

* lint

* Update example/lib/viewport_example.dart

Co-authored-by: Patrick Leonard <[email protected]>

* Center camera over Disneyland in simple map example

* Disable overview state viewport test on Android due to a bug

* Update example/integration_test/viewport_test.dart

Co-authored-by: Patrick Leonard <[email protected]>

---------

Co-authored-by: Patrick Leonard <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants