diff options
author | Steven Day <steve@mysociety.org> | 2012-11-16 10:31:17 +0000 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2012-11-26 12:46:43 +0000 |
commit | 6fea8abb2f4770e4a16ae17fc5582124ff0a5420 (patch) | |
tree | 0be9ca1d41e3581a7700b6aa5f81c4b485dd9d77 /web/js | |
parent | b6061833fdcf893d89ba32d9e49140ac140f5b41 (diff) |
Make controls and initial zoom level work
Diffstat (limited to 'web/js')
-rw-r--r-- | web/js/map-OpenLayers.js | 7 | ||||
-rw-r--r-- | web/js/map-wmts-zurich.js | 57 |
2 files changed, 34 insertions, 30 deletions
diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index 2bc20af0c..d4bf7800c 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -258,7 +258,7 @@ $(function(){ // call that instead of setting the map up ourselves if(typeof fixmystreet.map_setup !== "undefined") { fixmystreet.map_setup(function () { - // TODO - can this go inside afterMapInit()? + // TODO - can this go inside afterMapInit() so it's not duped? if ($('html').hasClass('mobile') && fixmystreet.page == 'around') { $('#fms_pan_zoom').css({ top: '2.75em !important' }); } @@ -266,6 +266,11 @@ $(function(){ }); } else { + // TODO - can this go inside afterMapInit() so it's not duped? + if ($('html').hasClass('mobile') && fixmystreet.page == 'around') { + $('#fms_pan_zoom').css({ top: '2.75em !important' }); + } + // Create the basics of the map fixmystreet.map = new OpenLayers.Map("map", { controls: fixmystreet.controls, diff --git a/web/js/map-wmts-zurich.js b/web/js/map-wmts-zurich.js index 9e54f3b05..12cf1286f 100644 --- a/web/js/map-wmts-zurich.js +++ b/web/js/map-wmts-zurich.js @@ -8,27 +8,24 @@ */ function set_map_config(perm) { // This stuff is copied from js/map-bing-ol.js - // var permalink_id; - // if ($('#map_permalink').length) { - // permalink_id = 'map_permalink'; - // } - - // var nav_opts = { zoomWheelEnabled: false }; - // if (fixmystreet.page == 'around' && $('html').hasClass('mobile')) { - // nav_opts = {}; - // } - // fixmystreet.nav_control = new OpenLayers.Control.Navigation(nav_opts); - - // fixmystreet.controls = [ - // new OpenLayers.Control.Attribution(), - // new OpenLayers.Control.ArgParser(), - // fixmystreet.nav_control, - // new OpenLayers.Control.Permalink(permalink_id), - // new OpenLayers.Control.PanZoomFMS({id: 'fms_pan_zoom' }) - // ]; - // if (fixmystreet.map_type) { - // tile_base = fixmystreet.map_type; - // } + var permalink_id; + if ($('#map_permalink').length) { + permalink_id = 'map_permalink'; + } + + var nav_opts = { zoomWheelEnabled: false }; + if (fixmystreet.page == 'around' && $('html').hasClass('mobile')) { + nav_opts = {}; + } + fixmystreet.nav_control = new OpenLayers.Control.Navigation(nav_opts); + + fixmystreet.controls = [ + new OpenLayers.Control.Attribution(), + new OpenLayers.Control.ArgParser(), + fixmystreet.nav_control, + new OpenLayers.Control.Permalink(permalink_id), + new OpenLayers.Control.PanZoomFMS({id: 'fms_pan_zoom' }) + ]; fixmystreet.map_type = OpenLayers.Layer.WMTS; @@ -50,7 +47,8 @@ function init_zurich_map(after) { displayProjection: new OpenLayers.Projection("EPSG:21781"), maxExtent: new OpenLayers.Bounds(676000,241000,690000,255000), units: 'm', - scales: [ '250000', '125000', '64000', '32000', '16000', '8000', '4000', '2000', '1000', '500'] + scales: [ '250000', '125000', '64000', '32000', '16000', '8000', '4000', '2000', '1000', '500'], + controls: fixmystreet.controls }); var format = new OpenLayers.Format.WMTSCapabilities(); @@ -65,15 +63,17 @@ function init_zurich_map(after) { var capabilities = format.read(data); layer = format.createLayer(capabilities, { - // added by me - isBaseLayer: true, - // Mark/Matthew's layer: "Luftbild", matrixSet: "default028mm", // matrixSet: "nativeTileMatrixSet", requestEncoding: "REST", - isBaseLayer: true + isBaseLayer: true, + // Things from the original map-OpenLayers.js + zoomOffset: fixmystreet.zoomOffset, + transitionEffect: 'resize', + numZoomLevels: fixmystreet.numZoomLevels + }); // For some reason with OpenLayers 2.11 the format // returns a KVP url not a REST one, despite the settings @@ -86,10 +86,9 @@ function init_zurich_map(after) { centre = new OpenLayers.LonLat( fixmystreet.longitude, fixmystreet.latitude ); centre.transform( new OpenLayers.Projection("EPSG:4326"), - fixmystreet.map.getProjectionObject(), - fixmystreet.zoom || 5 + fixmystreet.map.getProjectionObject() ); - fixmystreet.map.setCenter(centre); + fixmystreet.map.setCenter(centre, fixmystreet.zoom || 3); // Call the after callback after(); |