Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/1252 control hajk programatically (#1272)
* Initial commit for #1252: - 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. * Added a generic text field that can be used to try out any hash params * Major addition to index.js that we'll need to investigate: - 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. * Quite a lot in here, but I'm basically done with 1 & 2 of the Methodology, as described in #1252. * Added 'env: browser' to eslintrc in order to get rid of 'Unknown variable: window' * Experimental: Added the OL Map object to the public Hajk API. * Implemented search functionality in the hash API: - 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. * Very much WIP, but I'll commit it for the record: - 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. * Cleaned up the AnchorModel API by making private properties private. * The 'clean' param is only added to the AnchorView's URL, never to the hash in browser's URL field. * URLs generated by anchor now only include the hash portion: - 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. * A little longer default delay on debounce * Added support for x & y, plus new param: p: - 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. * Minor fix: separator must by specified when calling .split() * Some comments and cleanups * Layer history and toggling almost done: - 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. * Fixed functionality for Hajk's group layers: - I think this is it. What a horrible mess… We must get rid of group layers * I had a nice long comment explaining the mess. Forgot to put the code next to it, fixes here. * Removed a log message * Got rid of a (probably) unneeded timeout. * Extended the embedded example page. * Added `enableAppStateInHash` option to dotnet backend * Fixed scroll-zoom "jump"-issue. Zoom should be parsed as float - not int * Fixed another zoom-parsing issue * Fixed missing delay in debounce Co-authored-by: Henrik Hallberg <43059093+Hallbergs@users.noreply.github.com>
- Loading branch information