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

Enable zoom by box selection #319

Closed
wants to merge 5 commits into from
Closed

Conversation

benoitblanc
Copy link
Contributor

Hi,

This PR introduces a new enableZoomByBoxSelection option for Zoom(In|Out)Plugin to allow user to zoom by box selection. I needed to update MapSelection to make it work, I don't think I breaks something for other plugins that use this component but I'm not sure...

I tried to reproduce behavior for Zoom buttons in QGIS Desktop.

Here is a screencast with enableZoomByBoxSelection: false for ZoomInPlugin (actual behavior) and enableZoomByBoxSelection: true for ZoomOutPlugin:

QWCZoomByBox

Thanks for the review !

This feature has been funded by Grand Lyon Métropole https://www.grandlyon.com/

condition: ol.events.condition.shiftKeyOnly
condition: () => {
return ["ZoomIn", "ZoomOut"].includes(this.props.currentTask) || ol.events.condition.shiftKeyOnly;
}
Copy link
Member

Choose a reason for hiding this comment

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

I think you can generally simplify the condition to return true, shiftKeyOnly looks like leftover code, and I don't think it makes any sense here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought it was used by the shift+drag zoom already implemented but nope. I have removed all the condition

if (this.props.currentTask !== null && this.props.currentTask === this.state.task && this.state.disabled) {
this.props.setCurrentTask(null);
}
if (this.props.currentTask === this.state.task && prevProps !== this.props) {
Copy link
Member

Choose a reason for hiding this comment

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

If you write this.props.click && this.props.click !== prevProps.click here and directly use this.props.click.coordinate below you can simplify the code

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Resolved

@manisandro
Copy link
Member

A general remark: Does this conflict/overlap with the already implemented shift+drag zoomin?

@benoitblanc
Copy link
Contributor Author

A general remark: Does this conflict/overlap with the already implemented shift+drag zoomin?

No, it does not conflict with this feature. I thought it was implemented with the MapSelection component but it is not the case. So you can use this shift+drag zoom feature without this new option

if (this.props.currentTask !== null && this.props.currentTask === this.state.task && this.state.disabled) {
this.props.setCurrentTask(null);
}
if (this.props.currentTask === this.state.task && prevProps !== this.props && this.props.click !== prevProps.click) {
Copy link
Member

@manisandro manisandro Mar 4, 2024

Choose a reason for hiding this comment

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

this.props.currentTask === this.state.task && this.props.click && this.props.click !== prevProps.click

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks 🤦

@manisandro
Copy link
Member

I'd propose these additional changes [1], what do you think?

[1] db228da

@benoitblanc
Copy link
Contributor Author

I'd propose these additional changes [1], what do you think?

[1] db228da

Yes I agree with all of your changes, thanks.

For don't automatically exit task when zoom limit reached, I added it at the end of my PR because I wanted to exit the task to not have a zoom-in|out cursor for the user when he could not zoom because he has reached the limit, but I'm ok to keep this as current task. So user could still draw drag-box but zoom should not have effect I guess

@manisandro
Copy link
Member

So user could still draw drag-box but zoom should not have effect I guess

It will just re-center the map without changing the zoom level, which I think is not a bad behaviour.

@manisandro
Copy link
Member

Manually merged, thanks!

@manisandro manisandro closed this Mar 5, 2024
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