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

Support partial application state in the URL (was: Enhancement Requests) #481

Closed
RenoSun opened this issue Jan 4, 2018 · 6 comments
Closed

Comments

@RenoSun
Copy link

RenoSun commented Jan 4, 2018

Hi Jackie,

Here are the features that I always wish MapGuide/AIMS Fusion will provide by default:

  1. Layers/Layers Groups turn on/off history stored with URL parameters. Therefore, the users may share the URL with each other, and refresh the web page without turn on/off whole bunch layers or layer groups (including base layers) again.
    ex: hg=Cadastral,Zoning&hl=Roads&sl=QBIncorporationHistory,QBZoning

  2. Current map extent can be stored with URL parameters, and keep being updated when the user zoom in/out, panning around the map.
    ex: curextent=-13854516.504702,6334618.2438916,-13853592.691556,6335079.2547184

  3. Auto Select and Zoom to the extent of selection by using URL parameters.
    https://mapguide.wordpress.com/2013/06/11/autodesk-infrastructure-map-server-auto-zoom-on-load/

ex: layer=QBParcels&attribute=QBID&attvalue=1012,1013

I just think these are really handy features to have. or please just let me know what codes should I modify with mapguide-react-layout.

Please let me know your thoughts.

Thank you for building mapguide-react-layout!

@jumpinjackie
Copy link
Owner

We basically need to integrate a router component (or a clean wrapper over window.history that takes care of browser quirks) where we can encode application state into the URL at any time and to be able to read said state from it. The problem here is that there's so many to choose from, bundle size is of concern.

@jumpinjackie jumpinjackie changed the title Enhancement Requests Support partial application state in the URL (was: Enhancement Requests) Jan 5, 2018
@RenoSun
Copy link
Author

RenoSun commented Jan 5, 2018

I am no professional in founding the best application state encoder, but hope you or others may provide decent suggestion.

Something like react-url-query?

@jumpinjackie
Copy link
Owner

Hey, you're good at this library hunting thing! I'll take a look at this.

jumpinjackie added a commit that referenced this issue Feb 5, 2018
…s react-url-query to selectively auto-sync state into the URL. The state that is currently pushed to the URL is:

 - Session ID
 - Current View (x/y/scale)
 - Current active map

NOTE: Modifying the URL and hitting enter will do a full refresh, but will incorporate the URL parameters in (re-)initializing the application.
jumpinjackie added a commit that referenced this issue Feb 5, 2018
…E, but the URL state propagation doesn't work here anyways, which is fine for now. We just don't want it to error startup in IE.
@jumpinjackie
Copy link
Owner

Ok, react-url-query appears to be a winner. We now have partial application state being pushed to the URL.

Observe the scale parameter in the URL auto-updating upon change of view and view state being restored in the gif below.

url-state

Currently this pushes to the URL:

  • Session ID
  • Current View (x/y/scale)

This doesn't work at the moment in IE. But I'm not overly concerned there. Not everything can be made to work in IE.

@jumpinjackie jumpinjackie added this to the 0.11 milestone Feb 5, 2018
jumpinjackie added a commit that referenced this issue Feb 6, 2018
 - Use deterministic map names
   - For Flexible Layouts, this is the map group id
   - For Web Layouts, this is the name of the referenced map definition
 - With deterministic map names we can now push the current active map name to the url state.
 - When loading if map parameter is present, we DESCRIBERUNTIMEMAP instead of CREATERUNTIMEMAP on viewer init, allowing us to resume with the map state we left off.
jumpinjackie added a commit that referenced this issue Feb 6, 2018
 - Add a safePropGet helper to reduce boilerplate of null checking property access
 - Track layer/group visibility states to URL
@jumpinjackie jumpinjackie modified the milestones: 0.11, 0.12 Feb 16, 2018
@jumpinjackie
Copy link
Owner

The question of how best to persist selection state in the URL we'll move off to the next milestone

@jumpinjackie
Copy link
Owner

For 0.12 the missing piece of application state (selection set) is now persisted between browser reloads.

We just stash a copy of the selection set into local storage on every selection action and restore it along with the other runtime map state on viewer startup if the browser reloaded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants