]> git.openstreetmap.org Git - rails.git/commitdiff
Avoid making the map scroll when adding a new note
authorTom Hughes <tom@compton.nu>
Sun, 3 Feb 2013 16:07:47 +0000 (16:07 +0000)
committerTom Hughes <tom@compton.nu>
Sun, 3 Feb 2013 16:07:47 +0000 (16:07 +0000)
app/assets/javascripts/index/notes.js.erb

index c02c633dc236726052a9aacf44bf4a2f722d3eb5..43374012963f271c4084cc5320b51c7dcdf89679 100644 (file)
@@ -184,7 +184,23 @@ $(document).ready(function () {
 
     map.addLayer(noteLayer);
 
 
     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
       icon: noteIcons["new"],
       opacity: 0.7,
       draggable: true