From: Tom Hughes Date: Sun, 3 Feb 2013 16:07:47 +0000 (+0000) Subject: Avoid making the map scroll when adding a new note X-Git-Tag: live~5052^2~35 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/40b3c82?ds=sidebyside Avoid making the map scroll when adding a new note --- diff --git a/app/assets/javascripts/index/notes.js.erb b/app/assets/javascripts/index/notes.js.erb index c02c633dc..433740129 100644 --- a/app/assets/javascripts/index/notes.js.erb +++ b/app/assets/javascripts/index/notes.js.erb @@ -184,7 +184,23 @@ $(document).ready(function () { map.addLayer(noteLayer); - var marker = L.marker(map.getCenter(), { + var mapSize = map.getSize(); + var markerPosition; + + if (mapSize.y > 800) + { + markerPosition = [mapSize.x / 2, mapSize.y / 2]; + } + else if (mapSize.y > 400) + { + markerPosition = [mapSize.x / 2, 400]; + } + else + { + markerPosition = [mapSize.x / 2, mapSize.y]; + } + + var marker = L.marker(map.containerPointToLatLng(markerPosition), { icon: noteIcons["new"], opacity: 0.7, draggable: true