Skip to content

Commit

Permalink
Bugfix: Link for shared maps without context
Browse files Browse the repository at this point in the history
If you use the share functionality in a map, that is not created out of a context,
the shared link will not show the correct center and zoom, as long as the /config
part in the URL is missing.
As the documentations states in
https://docs.mapstore.geosolutionsgroup.com/en/latest/developer-guide/map-query-parameters/#center-zoom
and in
https://docs.mapstore.geosolutionsgroup.com/en/latest/developer-guide/map-query-parameters/#marker-zoom
that such a /config part should be part of configured URLs, this fix adds the /config part

Test is adapted to the new solution.

Bugfix on behalf of DB Systel GmbH
  • Loading branch information
petra-schanz committed Dec 11, 2024
1 parent 4d5ca88 commit d7b3ce7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('withShareTool enhancer', () => {
expect(sharePanel).toExist('Share panel doesn\'t exist');
const directLink = sharePanel.querySelector('#sharePanel-tabs-pane-1 .input-link input');
expect(directLink).toExist('directLink doesn\'t exist');
expect(directLink.value).toBe(window.location.origin + window.location.pathname + "#/" + FAKE_RESOURCE_PATH);
expect(directLink.value).toBe(window.location.origin + window.location.pathname + "#/" + FAKE_RESOURCE_PATH + '/config');
});
it('URL is generated using application path', () => {
const Sink = addSharePanel(createSink(() => {}));
Expand All @@ -67,8 +67,8 @@ describe('withShareTool enhancer', () => {
expect(sharePanel).toExist('Share panel doesn\'t exist');
const directLink = sharePanel.querySelector('#sharePanel-tabs-pane-1 .input-link input');
expect(directLink).toExist('directLink doesn\'t exist');
expect(directLink.value).toBe(FAKE_RESOURCE_URL);
expect(directLink.value).toBe("http://some-location/mapstore/#/FAKE_RESOURCE_PATH"); // double check
expect(directLink.value).toBe(FAKE_RESOURCE_URL + '/config');
expect(directLink.value).toBe("http://some-location/mapstore/#/FAKE_RESOURCE_PATH/config"); // double check
document.getElementById('sharePanel-tabs-tab-3').click();
const codeBlock = document.getElementsByTagName('code')[0];
expect(codeBlock).toExist();
Expand Down
1 change: 1 addition & 0 deletions web/client/components/share/SharePanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ class SharePanel extends React.Component {
const { settings, advancedSettings, mapType, viewerOptions } = this.props;
const shouldRemoveSectionId = !settings.showSectionId && advancedSettings && advancedSettings.sectionId;
let shareUrl = getSharedGeostoryUrl(removeQueryFromUrl(this.props.shareUrl), shouldRemoveSectionId);
if (!shareUrl.endsWith('config')) shareUrl += `${!shareUrl.endsWith('/') ? '/' : ''}config`;
if (settings.bboxEnabled && advancedSettings && advancedSettings.bbox && this.state.bbox) shareUrl = `${shareUrl}?bbox=${this.state.bbox}`;
if (settings.showHome && advancedSettings && advancedSettings.homeButton) shareUrl = `${shareUrl}?showHome=true`;
if (settings.centerAndZoomEnabled && advancedSettings && advancedSettings.centerAndZoom) {
Expand Down

0 comments on commit d7b3ce7

Please sign in to comment.