diff options
author | Matthew Somerville <matthew@mysociety.org> | 2012-03-27 15:35:33 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2012-03-27 15:35:33 +0100 |
commit | b199ab1679bdd14fe4ec4474f4d973ab0ee2992a (patch) | |
tree | 2d2d090952ee2689d0bae6f518b0ded2604b9d62 /web/js/map-OpenLayers.js | |
parent | c93cb823dafba47191f14fd7b31cf7b9d0cf37e0 (diff) | |
parent | 4c48e716dfd815764f730a58cf2ebd3cb22bb67f (diff) |
Merge branch 'bromley-fe' into bromley
Diffstat (limited to 'web/js/map-OpenLayers.js')
-rw-r--r-- | web/js/map-OpenLayers.js | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index 79740de78..5f60a4437 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -236,7 +236,7 @@ $(function(){ if (fixmystreet.state_map && fixmystreet.state_map == 'full') { // TODO Work better with window resizing, this is pretty 'set up' only at present - var q = $(window).width() / 4; + var q = $('#map_box').width() / 4; // Need to try and fake the 'centre' being 75% from the left fixmystreet.map.pan(-q, -25, { animate: false }); fixmystreet.map.events.register("movestart", null, function(e){ @@ -463,7 +463,12 @@ OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, { // If we clicked the map somewhere inconvenient var sidebar = $('#report-a-problem-sidebar'); if (sidebar.css('position') == 'absolute') { - var w = sidebar.width(), h = sidebar.height(), o = sidebar.offset(); + var w = sidebar.width(), h = sidebar.height(), + o = sidebar.offset(), + $map_box = $('#map_box'), bo = $map_box.offset(); + // e.xy is relative to top left of map, which might not be top left of page + e.xy.x += bo.left; + e.xy.y += bo.top; if (e.xy.y <= o.top || (e.xy.x >= o.left && e.xy.x <= o.left + w + 24 && e.xy.y >= o.top && e.xy.y <= o.top + h + 64)) { // top of the page, pin hidden by header; // or underneath where the new sidebar will appear @@ -472,7 +477,7 @@ OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, { fixmystreet.map.getProjectionObject() ); var p = fixmystreet.map.getViewPortPxFromLonLat(lonlat); - p.x -= $(window).width() / 3; + p.x -= $map_box.width() / 3; lonlat = fixmystreet.map.getLonLatFromViewPortPx(p); fixmystreet.map.panTo(lonlat); } |