-
Notifications
You must be signed in to change notification settings - Fork 9
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
Capturing camera parameters within the URL #334
Capturing camera parameters within the URL #334
Conversation
This pull request is automatically being deployed by Amplify Hosting (learn more). |
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.
We have src\utils\url-utils.ts
with some logic for tileset
param. I'd add there functions viewStateToUrlParams
and urlParamsToViewState
.
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 you add tests for new functions
src/utils/url-utils.ts
Outdated
new URLSearchParams(window.location.search) | ||
); | ||
const { longitude, latitude, pitch, bearing, zoom } = viewState.main; | ||
setSearchParams( |
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.
I don't like having a state setter outside of react. I was about returning some ready to use object and set it in the component.
We can have it here but need to make a TSDoc comments anyway.
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.
Done
src/utils/url-utils.ts
Outdated
@@ -57,3 +57,35 @@ const prepareTilesetUrl = (parsedUrl) => { | |||
.concat("layers/0"); | |||
return `${parsedUrl.origin}${replacedPathName}${parsedUrl.search}`; | |||
}; | |||
|
|||
export const viewStateToUrlParams = (viewState, setSearchParams) => { |
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.
Add TSDoc and tests for new functions
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.
Done
src/utils/url-utils.ts
Outdated
); | ||
}; | ||
|
||
export const urlParamsToViewState = (viewState, setStateUrlViewStateParams) => { |
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.
Ditto
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.
Done
src/utils/url-utils.ts
Outdated
urlViewStateParams[viewStateParam[0]] = parseFloat(viewStateParam[1]); | ||
} | ||
} | ||
setStateUrlViewStateParams(urlViewStateParams); |
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.
Ditto: I prefer returning a value and setting the state in the component.
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.
Done
No description provided.