aboutsummaryrefslogtreecommitdiffstats
path: root/web/js/map-OpenLayers.js
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2012-02-23 18:04:50 +0000
committerMatthew Somerville <matthew@mysociety.org>2012-02-23 18:04:50 +0000
commit459e6cb9d0c5aa1ccd56269c11c3c14a79c05726 (patch)
tree054fb96a0be6c49142c92924e069fb6c05ae83e3 /web/js/map-OpenLayers.js
parent527be3a9bd51b898f1da6c0138d565f04f854036 (diff)
Do some zoom centre faking trickery so that zooming in and out does as you would hopefully expect.
Diffstat (limited to 'web/js/map-OpenLayers.js')
-rw-r--r--web/js/map-OpenLayers.js23
1 files changed, 22 insertions, 1 deletions
diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js
index e7848c5bb..2eb949b76 100644
--- a/web/js/map-OpenLayers.js
+++ b/web/js/map-OpenLayers.js
@@ -208,7 +208,28 @@ $(function(){
fixmystreet.map.setCenter(centre, fixmystreet.zoom || 3);
}
if ($('#map_box').data('size')=='full') {
- fixmystreet.map.pan(-200, -25, { animate: false });
+ // TODO Work better with window resizing, this is pretty 'set up' only at present
+ var q = $(window).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){
+ fixmystreet.map.moveStart = { zoom: this.getZoom(), center: this.getCenter() };
+ });
+ fixmystreet.map.events.register("zoomend", null, function(e){
+ if ( !this.getCenter().equals(fixmystreet.map.moveStart.center) ) {
+ // Centre has moved, e.g. by double-click. Same whether zoom in or out
+ fixmystreet.map.pan(-q, -25, { animate: false });
+ return;
+ }
+ var zoom_change = this.getZoom() - fixmystreet.map.moveStart.zoom;
+ if (zoom_change == -1) {
+ // Zoomed out, need to re'centre'
+ fixmystreet.map.pan(-q/2, 0, { animate: false });
+ } else if (zoom_change == 1) {
+ // Using a zoom button
+ fixmystreet.map.pan(q, 0, { animate: false });
+ }
+ });
}
if (document.getElementById('mapForm')) {