openstreetmap/openstreetmap-website — pull request #378 by jfirebaugh (2013-07-23 20:57:40+00:00)
Title: Use a hash anchor for location/zoom persistence

Using a hash that updates as the map is panned and zoomed is
a direct and obvious way to persist the map state across refreshes,
to bookmark particular locations, and to share links with other
users.

Given the numerous existing ways that the initial state of the
map can be determined, this will require tweaking and refinement.
I'm submitting this PR in very early stages to get feedback and
suggestions.

The current behavior is to add a #zoom/lon/lat hash, and to redirect
requests with zoom, lon, lat query parameters to the equivalent
hash. (Other query parameters are preserved.)

I'm assuming that we will want the lon, lat, and zoom in the hash to
take precedence over all other sources for location (e.g. cookie, home
location, bbox param, object). For example, when I load http://www.openstreetmap.org/?way=52477381,
pan around a bit, and refresh, I expect to get the view I had when I
refreshed, not for the map to recenter on the bridge as it currently
does.

I'm also assuming we'll want to update the places where we generate
links with lat/lon/zoom query parameters to use a hash instead.

We probably want to extend the state stored in the hash to include
at least the active base and overlay layers.

In the map-ui pull request, @seav raised a concern about polluting
the browser history. Fortunately, this does not happen -- `location.replace`
does not generate a history entry, and is available all the way back
to IE6.