Skip to content

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

@benoitblanc benoitblanc force-pushed the zoom-to-bookmark-extent branch from 9a8e558 to 84375bb Compare February 29, 2024 10:37
@benoitblanc benoitblanc force-pushed the zoom-to-bookmark-extent branch from 6963a1e to 1f4003e Compare February 29, 2024 11:18
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
@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