<p>Using a hash that updates as the map is panned and zoomed is<br>
a direct and obvious way to persist the map state across refreshes,<br>
to bookmark particular locations, and to share links with other<br>
users.</p>
<p>Given the numerous existing ways that the initial state of the<br>
map can be determined, this will require tweaking and refinement.<br>
I'm submitting this PR in very early stages to get feedback and<br>
suggestions.</p>
<p>The current behavior is to add a #zoom/lon/lat hash, and to redirect<br>
requests with zoom, lon, lat query parameters to the equivalent<br>
hash. (Other query parameters are preserved.)</p>
<p>I'm assuming that we will want the lon, lat, and zoom in the hash to<br>
take precedence over all other sources for location (e.g. cookie, home<br>
location, bbox param, object). For example, when I load <a href="http://www.openstreetmap.org/?way=52477381">http://www.openstreetmap.org/?way=52477381</a>,<br>
pan around a bit, and refresh, I expect to get the view I had when I<br>
refreshed, not for the map to recenter on the bridge as it currently<br>
does.</p>
<p>I'm also assuming we'll want to update the places where we generate<br>
links with lat/lon/zoom query parameters to use a hash instead.</p>
<p>We probably want to extend the state stored in the hash to include<br>
at least the active base and overlay layers.</p>
<p>In the map-ui pull request, <a href="https://github.com/seav" class="user-mention">@seav</a> raised a concern about polluting<br>
the browser history. Fortunately, this does not happen -- <code>location.replace</code><br>
does not generate a history entry, and is available all the way back<br>
to IE6.</p>
<hr>
<h4>You can merge this Pull Request by running</h4>
<pre> git pull https://github.com/osmlab/openstreetmap-website hash</pre>
<p>Or view, comment on, or merge it at:</p>
<p> <a href='https://github.com/openstreetmap/openstreetmap-website/pull/378'>https://github.com/openstreetmap/openstreetmap-website/pull/378</a></p>
<h4>Commit Summary</h4>
<ul>
<li>Use leaflet-hash</li>
<li>Redirect lat/lon/zoom query params to hash</li>
</ul>
<h4>File Changes</h4>
<ul>
<li>
<strong>M</strong>
<a href="https://github.com/openstreetmap/openstreetmap-website/pull/378/files#diff-0">Vendorfile</a>
(4)
</li>
<li>
<strong>M</strong>
<a href="https://github.com/openstreetmap/openstreetmap-website/pull/378/files#diff-1">app/assets/javascripts/application.js</a>
(1)
</li>
<li>
<strong>M</strong>
<a href="https://github.com/openstreetmap/openstreetmap-website/pull/378/files#diff-2">app/assets/javascripts/index.js</a>
(2)
</li>
<li>
<strong>M</strong>
<a href="https://github.com/openstreetmap/openstreetmap-website/pull/378/files#diff-3">app/controllers/site_controller.rb</a>
(6)
</li>
<li>
<strong>M</strong>
<a href="https://github.com/openstreetmap/openstreetmap-website/pull/378/files#diff-4">test/functional/site_controller_test.rb</a>
(10)
</li>
<li>
<strong>A</strong>
<a href="https://github.com/openstreetmap/openstreetmap-website/pull/378/files#diff-5">vendor/assets/leaflet/leaflet.hash.js</a>
(159)
</li>
</ul>
<h4>Patch Links:</h4>
<ul>
<li><a href='https://github.com/openstreetmap/openstreetmap-website/pull/378.patch'>https://github.com/openstreetmap/openstreetmap-website/pull/378.patch</a></li>
<li><a href='https://github.com/openstreetmap/openstreetmap-website/pull/378.diff'>https://github.com/openstreetmap/openstreetmap-website/pull/378.diff</a></li>
</ul>