openstreetmap / openstreetmap-website

The Rails application that powers OpenStreetMap
https://www.openstreetmap.org/
GNU General Public License v2.0
2.16k stars 911 forks source link

Local site navigation #2973

Open lectrician1 opened 3 years ago

lectrician1 commented 3 years ago

Initial Problem Currently, the Query features tool/page has no ability to navigate back to the Query Features list without re-requesting the site/Overpass-API.

Example Untitled_ Nov 21, 2020 7_32 PM

Explanation Here, I query a point and click on an element. Then, I have to use the back-button for my browser to go back to the query list. Of course, this re-requests osm.org and in-turn, Overpass.

Reasoning & Request Sometimes I like to look at and browse a lot of elements (especially in element-dense cities) using the query tool. After I look at an element, I want to be able to go back to the link fast, without having to wait for the web page to reload. A dedicated back button that leads back to the Query page would do this.

Other Uses Other left-pane-using pages on the site could also use this functionality. For example, after viewing a changed element on a Changeset page, you should be able to easily go back to the Changeset you were viewing without having to use the back button for your browser.

A forward button could also be implemented.

tomhughes commented 3 years ago

So basically you want us to cache all the search results and implement the navigation ourselves with a full history inside javascript rather than leveraging the browser history as we do now?

It think that's pretty unlikely - it sounds like it would be a huge amount of work.

I mean if somebody wants to write it we could review it but I worry that it would be so large and complex that I would be concerned about merging it.

gravitystorm commented 3 years ago

javascript rather than leveraging the browser history as we do now?

The problem is that we don't cache the results in the browser history at all, as @lectrician1 demonstrates (and as I found recently too). When you hit the back button, it makes a second overpass request.

Personally I think the solution is to reduce the javascript in the first place, and use more server-side stuff. I think the results caching would work better if the call to overpass was moved server-side, and the browser is just requesting page fragments from rails, rather than talking to overpass directly. That way, the html is all cached normally in the browser, since it's not dependent on any javascript re-running after hitting the back button.

tomhughes commented 3 years ago

Well if you're lucky that might help but @lectrician1 is really asking for the opposite, to move everything client side so the client can keep a history and go back and forth without making calls to any servers.

mmd-osm commented 3 years ago

Server side rendering might be quite challenging due to the IP-based rate limiting on the overpass instance.