[openstreetmap-website] In certain situations, closing the pane with information about an element moves the center of map to a different position (#729)

M Somerville notifications at github.com
Wed May 27 21:47:01 UTC 2015


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.

Here are my steps to reproduce:
1. Go to http://www.openstreetmap.org/search?query=test#map=19/51.08844/-1.50910&layers=N (centred on the island in the river Test).
2. Click first search result (River, Test, Test Valley).
3. URL changes to http://www.openstreetmap.org/way/162828509 and then http://www.openstreetmap.org/way/162828509#map=18/51.08841/-1.50907&layers=N or similar (same centre, as you'd expect).
4. Close search results. URL changes to http://www.openstreetmap.org/#map=18/51.08841/-1.50813&layers=N 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.
5. Start panning the map, the map 'leaps' to be at these new hash co-ordinates immediately.

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

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

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!

---
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/issues/729#issuecomment-106088058
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20150527/5ceecb94/attachment.html>


More information about the rails-dev mailing list