-
Notifications
You must be signed in to change notification settings - Fork 72
feat: zoom to fit the provided features in the viewport #8082
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
Conversation
| * @param features | ||
| * the features to fit in the viewport | ||
| */ | ||
| public void zoomToFit(List<Feature> features) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally this would also be available on the View instance of the map. However, none of the configuration objects have any reference to the Map element to trigger JS calls. I'm not sure about adding one at the moment, as technically configuration objects can be shared between multiple map instances (though sharing the view seems extremely unlikely).
Still, I think it's fine to start only with this for now. The new API at least fits with having setCenter and setZoom methods on the Map. If this turns out to be an issue, we can spend more time on making it work through the view instance.
| // In order to allow calling this method before the map, or the view | ||
| // that contains it, is attached to the UI, this needs to be delayed | ||
| // with beforeClientResponse to ensure that the client-side connector | ||
| // has been initialized beforehand. | ||
| getElement().getNode() | ||
| .runWhenAttached(ui -> ui.beforeClientResponse(this, | ||
| context -> getElement().executeJs( | ||
| "this.$connector.zoomToFit($0, $1)", featureIds, | ||
| options))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could not find a better approach. In some form this needs to run after onAttach, which is responsible for creating the connector.
|
|
This ticket/PR has been released with Vaadin 25.0.0-alpha12. |



Description
Adds a
zoomToFitmethod to theMapcomponent that allows to fit the provided features within the viewport. The options allow to configure a padding for the viewport and an animation duration.Closes #3137
Type of change