[openstreetmap-website] Use a hash anchor for location/zoom persistence (#378)

John Firebaugh notifications at github.com
Tue Jul 23 20:57:42 UTC 2013


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.
You can merge this Pull Request by running:

  git pull https://github.com/osmlab/openstreetmap-website hash

Or you can view, comment on it, or merge it online at:

  https://github.com/openstreetmap/openstreetmap-website/pull/378

-- Commit Summary --

  * Use leaflet-hash
  * Redirect lat/lon/zoom query params to hash

-- File Changes --

    M Vendorfile (4)
    M app/assets/javascripts/application.js (1)
    M app/assets/javascripts/index.js (2)
    M app/controllers/site_controller.rb (6)
    M test/functional/site_controller_test.rb (10)
    A vendor/assets/leaflet/leaflet.hash.js (159)

-- Patch Links --

https://github.com/openstreetmap/openstreetmap-website/pull/378.patch
https://github.com/openstreetmap/openstreetmap-website/pull/378.diff

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20130723/52bb1735/attachment-0001.html>


More information about the rails-dev mailing list