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

Feature/1252 control hajk programatically #1272

Merged
merged 32 commits into from
Jan 25, 2023

Conversation

jacobwod
Copy link
Member

Closes #1252

Skarminspelning.2023-01-24.kl.14.55.43.mov

- Added an example page that embeds the locally running Hajk instance.
- Added two buttons to the example. They can be used to control the zoom level.
- Added a listener to App.js that will trigger onhashchange.
- Implemeted changing zoom level by changing the z-value of hash string.
- In order to allow embedding parent documents to read out some values from our Hajk instance, I had to add an object to the global object of Hajk.
- It's called 'hajkPublicApi', but it's not a real API (yet?). It only exposes the View's zoom limits.
- This can be expanded to a real public API with executable functions, or completely removed if we see problems with this approach.
- The q paramter is updated when user types in the search bar
- If the map loads with the q parameter OR the q parameter's value changes, search is invoked.
- Added a debouncer to utils, can come in handy in other places too.
- AnchorModel now part of core, will get initated no matter the settings for Anchor plugin
- A asynchronous debounce helper takes care of not re-creating the URL too often.
- Anchor plugin needs some more work to work with the new solution. The main question that remains is: how should we treat the 'clean' parameter? If we update it in the URL immitiately, we would expect the map to get cleaned up and the Anchor view would disappear. But if we don't put 'clean' into the hash, it must be taken care of somewhere else, or else it will be overriden the next time user does something that triggers URL regeneration, so that 'clean's value will be set to false again. Fixable but we need to decide on this one.
- Search params are used only internally but removed prior return
- We still support both search and hash params on init (as we merge them both in AppModel), but I see no need in generating the search params portion now, when we work with the hash portion under the hood.
- Changes to x & y trigger now View animation, just as z change does. This means we have a map that stores its' state in the URL's hash, including full compatibility with browser's history mechanism.
- Added a new param: p. It is meant to store the currently visible plugin(s). With this option, app's state now also includes the most recently shown plugins. They also follow with the link, so when URL is shared, the plugin visibility is also shared.
- As usual, group layers are an issue. They toggel correctly in map, but the sublayers aren't selected correctly in LayerSwitcher. Will need to take a look into that too.
- But I'm commiting now, as this has grown pretty big already. So, two things:
  - l and gl parameters are now respected
  - THIS ENTIRE FUNCTIONALITY IS NOW BEHIND A FLAG IN ADMIN: enableAppStateInHash. I think it's neccessary to make it optional at this stage.
- I think this is it. What a horrible mess… We must get rid of group layers
@jacobwod jacobwod added module:client/core Core functionality (not a plugin) new feature Request for adding/changing functionality labels Jan 24, 2023
@jacobwod jacobwod added this to the 3.12 milestone Jan 24, 2023
@jacobwod jacobwod self-assigned this Jan 24, 2023
@jacobwod jacobwod linked an issue Jan 24, 2023 that may be closed by this pull request
Hallbergs
Hallbergs previously approved these changes Jan 25, 2023
Copy link
Member

@Hallbergs Hallbergs left a comment

Choose a reason for hiding this comment

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

Found some issues regarding the zoom-change.

Zoom should be parsed as float - not int
Copy link
Member

@Hallbergs Hallbergs left a comment

Choose a reason for hiding this comment

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

Very nice! Works great! 🥇 🔥 🥳 💯

@jesade-vbg
Copy link
Contributor

"Snajsigt!", as you say in Swedish. Nice work!

@jacobwod jacobwod merged commit 476d51c into develop Jan 25, 2023
@jacobwod jacobwod deleted the feature/1252-control-hajk-programatically branch January 25, 2023 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module:client/core Core functionality (not a plugin) new feature Request for adding/changing functionality
Projects
Hajk
  
Awaiting triage
Development

Successfully merging this pull request may close these issues.

Add an API to control certain Hajk features programmatically
3 participants