Skip to content

Commit

Permalink
Avoid making the map scroll when adding a new note
Browse files Browse the repository at this point in the history
  • Loading branch information
tomhughes committed Feb 3, 2013
1 parent ae48206 commit 40b3c82
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion app/assets/javascripts/index/notes.js.erb
Expand Up @@ -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"], icon: noteIcons["new"],
opacity: 0.7, opacity: 0.7,
draggable: true draggable: true
Expand Down

0 comments on commit 40b3c82

Please sign in to comment.