aboutsummaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2012-03-26 18:59:08 +0100
committerMatthew Somerville <matthew@mysociety.org>2012-03-26 18:59:08 +0100
commitffd6301db1e3709fdb3072b6ee76355971ead603 (patch)
treeabec2546c46acfaa760425eca6c01e39c24ae394 /web
parentbf811df17f12b4584c28fb9437577fdf022fc221 (diff)
Adjust figures for when map might not be top left of page.
Diffstat (limited to 'web')
-rw-r--r--web/js/map-OpenLayers.js11
1 files changed, 8 insertions, 3 deletions
diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js
index 272fd6c12..aa2b2b2eb 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){
@@ -459,7 +459,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
@@ -468,7 +473,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);
}