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

Zoom to bookmark extent #316

Merged
merged 3 commits into from
Feb 29, 2024
Merged

Conversation

benoitblanc
Copy link
Contributor

@benoitblanc benoitblanc commented Feb 28, 2024

Hi,

This PR allows user to only zoom to a bookmark extent without changing theme or load/open the bookmark in the current window or new tab.

Thanks for the review

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

resolveBookmark(bookmarkkey, (params) => {
const scale = parseFloat(params.s);
const zoom = MapUtils.computeZoom(this.props.mapScales, scale);
const center = params.c.split(/[;,]/g).map(x => parseFloat(x));
Copy link
Member

Choose a reason for hiding this comment

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

Depending on urlPositionFormat in config.json, the url parameters may contain c and s, or e for extent. You might also want to handle the e case 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 think it is resolved with my new commit

this.props.zoomToPoint(center, zoom, this.props.mapCrs);
} else if ('e' in params) {
const bounds = (params.e).split(',').map(n => parseFloat(n));
this.props.zoomToExtent(bounds, this.props.mapCrs);
Copy link
Member

Choose a reason for hiding this comment

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

Sorry I forgot earlier, there is also the urlPositionCrs config option, which will add a crs URL parameter if urlPositionCrs is different than mapCrs. Something like params.crs ?? this.props.mapCrs should do.

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, I was not aware of these options

@manisandro manisandro merged commit 630d0cf into qgis:master Feb 29, 2024
2 checks passed
@manisandro
Copy link
Member

Thanks!

@benoitblanc benoitblanc deleted the zoom-to-bookmark-extent branch February 29, 2024 13:13
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