OpenWaterFoundation / owf-app-infomapper-ng

Open Water Foundation InfoMapper web application for menu-driven maps and visualizations, using Angular
GNU General Public License v3.0
1 stars 2 forks source link

Add support for URL query parameters to represent application state #381

Open smalers opened 3 years ago

smalers commented 3 years ago

This is lower priority but if figured out would be a big step forward.

It would be useful to represent the state of the application with URL query parameters. For example, see the image below, which shows how some layers have been turned off. The URL might look something like:

http://poudre.openwaterfoundation.org/latest#/map/entities-basins?huc12.enabled=false

where huc12 is the layer ID and .enabled is a property. We need to figure out the mechanics of doing such a thing and then spend time on the specification that would map URL to application state properties. The application would need to update the URL when selections are made and would need to be able to recreate a UI state based on URL with query parameters. It is important to understand the parts of the URL, including the main resource, the query parameters to modify state, and the hash fragment. As shown above the query parameter is in the fragment, which may not be correct. However, I tried some bogus query parameters in the hash fragment and the correct app page was displayed.

image

smalers commented 3 years ago

Here is an example of URL fragment that causes specific state to be shown:

NRCS SNOTEL Map

cnlane commented 3 years ago

I have used some Angular url classes, namely: Location.path() (https://angular.io/api/common/Location), route.params (https://angular.io/api/router/ActivatedRoute) to respond to url information or create "back" paths. Maybe the Angular group has more information.

smalers commented 3 years ago

Catherine found the following article:

Mastering RouterLink