diff options
Diffstat (limited to 'web/js/map-OpenLayers.js')
-rw-r--r-- | web/js/map-OpenLayers.js | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index 88dc6d69e..62e94ed29 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -411,14 +411,30 @@ OpenLayers.Control.PanZoomFMS = OpenLayers.Class(OpenLayers.Control.PanZoom, { /* Overriding Permalink so that it can pass the correct zoom to OSM */ OpenLayers.Control.PermalinkFMS = OpenLayers.Class(OpenLayers.Control.Permalink, { - updateLink: function() { + _updateLink: function(alter_zoom) { var separator = this.anchor ? '#' : '?'; var href = this.base; if (href.indexOf(separator) != -1) { href = href.substring( 0, href.indexOf(separator) ); } - href += separator + OpenLayers.Util.getParameterString(this.createParams(null, this.map.getZoom()+fixmystreet.zoomOffset)); + var center = this.map.getCenter(); + if ( center && fixmystreet.state_map && fixmystreet.state_map == 'full' ) { + // Translate the permalink co-ords so that 'centre' is accurate + var $content = $('.content'), mb = $('#map_box'), + q = ( $content.offset().left - mb.offset().left + $content.width() ) / 2; + if (q < 0) { q = 0; } + var p = this.map.getViewPortPxFromLonLat(center); + p.x += q; + p.y += 25; + center = this.map.getLonLatFromViewPortPx(p); + } + + var zoom = this.map.getZoom(); + if ( alter_zoom ) { + zoom += fixmystreet.zoomOffset; + } + href += separator + OpenLayers.Util.getParameterString(this.createParams(center, zoom)); // Could use mlat/mlon here as well if we are on a page with a marker if (this.anchor && !this.element) { window.location.href = href; @@ -426,6 +442,14 @@ OpenLayers.Control.PermalinkFMS = OpenLayers.Class(OpenLayers.Control.Permalink, else { this.element.href = href; } + }, + updateLink: function() { + this._updateLink(0); + } +}); +OpenLayers.Control.PermalinkFMSz = OpenLayers.Class(OpenLayers.Control.PermalinkFMS, { + updateLink: function() { + this._updateLink(1); } }); |