aboutsummaryrefslogtreecommitdiffstats
path: root/web/js/map-OpenLayers.js
diff options
context:
space:
mode:
authorDave Whiteland <dave@mysociety.org>2012-04-29 18:14:32 +0100
committerDave Whiteland <dave@mysociety.org>2012-04-29 18:14:32 +0100
commit16061e060354affb25701a8c6111ee30df2ac19c (patch)
treea2d0f949b532f582becff31ef7f79b5deacc4186 /web/js/map-OpenLayers.js
parentb38ba427f7facd6e8042ae667b5b3bac1724803a (diff)
parent1fc50dcc7f65ae04055a803579445a9397e3ffdf (diff)
Merge branch 'master' into barnet-integration
(prior to go-live... amongst other things, the Barnet web templates had changed. NB conflict with carton.lock, accepted master in full) Conflicts: carton.lock
Diffstat (limited to 'web/js/map-OpenLayers.js')
-rw-r--r--web/js/map-OpenLayers.js12
1 files changed, 9 insertions, 3 deletions
diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js
index 272fd6c12..1574754c9 100644
--- a/web/js/map-OpenLayers.js
+++ b/web/js/map-OpenLayers.js
@@ -236,7 +236,8 @@ $(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 $content = $('.content'),
+ q = ( $content.offset().left + $content.width() ) / 2;
// 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 +460,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 +474,7 @@ OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, {
fixmystreet.map.getProjectionObject()
);
var p = fixmystreet.map.getViewPortPxFromLonLat(lonlat);
- p.x -= $(window).width() / 3;
+ p.x -= ( o.left + w ) / 2;
lonlat = fixmystreet.map.getLonLatFromViewPortPx(p);
fixmystreet.map.panTo(lonlat);
}