<p>I have this happen to be all the time when using the OSM site, so I tried to help track it down. I think this is something to do with the multiple calls to update the state/hash when you close the sidebar, and it getting confused as to where the centre of the map is.</p>

<p>Here are my steps to reproduce:<br>
1. Go to <a href="http://www.openstreetmap.org/search?query=test#map=19/51.08844/-1.50910&layers=N">http://www.openstreetmap.org/search?query=test#map=19/51.08844/-1.50910&layers=N</a> (centred on the island in the river Test).<br>
2. Click first search result (River, Test, Test Valley).<br>
3. URL changes to <a href="http://www.openstreetmap.org/way/162828509">http://www.openstreetmap.org/way/162828509</a> and then <a href="http://www.openstreetmap.org/way/162828509#map=18/51.08841/-1.50907&layers=N">http://www.openstreetmap.org/way/162828509#map=18/51.08841/-1.50907&layers=N</a> or similar (same centre, as you'd expect).<br>
4. Close search results. URL changes to <a href="http://www.openstreetmap.org/#map=18/51.08841/-1.50813&layers=N">http://www.openstreetmap.org/#map=18/51.08841/-1.50813&layers=N</a> or similar (note the longitude changes to the East) but map jerks to be still showing centre of 51.08841/-1.50907 – the URL and the map now no longer match.<br>
5. Start panning the map, the map 'leaps' to be at these new hash co-ordinates immediately.</p>

<p>If you start the process at the end of step 3, i.e. load afresh <a href="http://www.openstreetmap.org/way/162828509#map=18/51.08841/-1.50907&layers=N">http://www.openstreetmap.org/way/162828509#map=18/51.08841/-1.50907&layers=N</a> and close the search results, the hashed co-ordinates do not change and so panning the map works fine.</p>

<p>Adding a catch to calls to replaceState shows that when you close the search results at step 4, replaceState is called three times, with:<br>
#map=18/51.08841/-1.50813&layers=N<br>
#map=18/51.08841/-1.51001&layers=N<br>
#map=18/51.08841/-1.50813&layers=N</p>

<p>The second of these is what we want, and is what the map shows, just the URL ends up disagreeing. I tried investigating a bit further from the JavaScript, but am afraid I couldn't work it out, sorry. Hope that's helpful anyway!</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br>Reply to this email directly or <a href="https://github.com/openstreetmap/openstreetmap-website/issues/729#issuecomment-106088058">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/ABWnLXT1GaSssujJH8VMKOq7G9zSiuErks5oNjLVgaJpZM4BzTx0.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
  <div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
    <link itemprop="url" href="https://github.com/openstreetmap/openstreetmap-website/issues/729#issuecomment-106088058"></link>
    <meta itemprop="name" content="View Issue"></meta>
  </div>
  <meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>