From 01105c917f8f43bae9949de499a4a0268f5d2a0c Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Mon, 11 Jul 2016 16:31:51 +0100 Subject: [PATCH] Tweak WMTS JavaScript to match merged branch. Use $.each rather than .forEach. --- web/js/map-wmts-base.js | 17 +++++++---------- web/js/map-wmts-bristol.js | 6 +++--- web/js/map-wmts-zurich.js | 6 +++--- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/web/js/map-wmts-base.js b/web/js/map-wmts-base.js index c60afe4e1b3..c407e76dba1 100644 --- a/web/js/map-wmts-base.js +++ b/web/js/map-wmts-base.js @@ -1,29 +1,29 @@ // Functionality required by all OpenLayers WMTS base maps -function setup_wmts_base_map() { +fixmystreet.maps.setup_wmts_base_map = function() { fixmystreet.map_type = OpenLayers.Layer.WMTS; // Set DPI - default is 72 OpenLayers.DOTS_PER_INCH = fixmystreet.wmts_config.tile_dpi; fixmystreet.map_options = { - maxExtent: layer_bounds, + maxExtent: this.layer_bounds, units: 'm', scales: fixmystreet.wmts_config.scales }; fixmystreet.layer_options = []; - fixmystreet.wmts_config.layer_names.forEach(function(v, i) { + $.each(fixmystreet.wmts_config.layer_names, function(i, v) { fixmystreet.layer_options.push({ projection: new OpenLayers.Projection(fixmystreet.wmts_config.map_projection), - name: fixmystreet.wmts_config.layer_names[i], - layer: fixmystreet.wmts_config.layer_names[i], + name: v, + layer: v, formatSuffix: fixmystreet.wmts_config.tile_suffix.replace(".", ""), matrixSet: fixmystreet.wmts_config.matrix_set, requestEncoding: "REST", url: fixmystreet.wmts_config.tile_urls[i], style: fixmystreet.wmts_config.layer_style, - matrixIds: matrix_ids, + matrixIds: fixmystreet.maps.matrix_ids, tileOrigin: new OpenLayers.LonLat(fixmystreet.wmts_config.origin_x, fixmystreet.wmts_config.origin_y) }); }); @@ -33,7 +33,7 @@ function setup_wmts_base_map() { fixmystreet.bbox_strategy = new OpenLayers.Strategy.ReprojectBBOX({ ratio: 1 }); -} +}; OpenLayers.Strategy.ReprojectBBOX = OpenLayers.Class(OpenLayers.Strategy.BBOX, { getMapBounds: function() { @@ -51,6 +51,3 @@ OpenLayers.Strategy.ReprojectBBOX = OpenLayers.Class(OpenLayers.Strategy.BBOX, { CLASS_NAME: "OpenLayers.Strategy.ReprojectBBOX" }); - - -// \ No newline at end of file diff --git a/web/js/map-wmts-bristol.js b/web/js/map-wmts-bristol.js index 94ed2bdb232..3e5de0c27d6 100644 --- a/web/js/map-wmts-bristol.js +++ b/web/js/map-wmts-bristol.js @@ -3,13 +3,13 @@ */ // From the 'fullExtent' key from http://maps.bristol.gov.uk/arcgis/rest/services/base/2015_BCC_96dpi/MapServer?f=pjson -var layer_bounds = new OpenLayers.Bounds( +fixmystreet.maps.layer_bounds = new OpenLayers.Bounds( 268756.31099999975, // W 98527.70309999958, // S 385799.51099999994, // E 202566.10309999995); // N -var matrix_ids = [ +fixmystreet.maps.matrix_ids = [ { "identifier": "0", "supportedCRS": "urn:ogc:def:crs:EPSG::27700", @@ -119,7 +119,7 @@ fixmystreet.maps.config = function() { fixmystreet.controls.push( new OpenLayers.Control.PermalinkFMS('key-tool-problems-nearby', '/around') ); } - setup_wmts_base_map(); + this.setup_wmts_base_map(); }; fixmystreet.maps.marker_size_for_zoom = function(zoom) { diff --git a/web/js/map-wmts-zurich.js b/web/js/map-wmts-zurich.js index 1995cb4018d..fc1dfa08f65 100644 --- a/web/js/map-wmts-zurich.js +++ b/web/js/map-wmts-zurich.js @@ -3,13 +3,13 @@ */ // From 'fullExtent' from http://www.gis.stadt-zuerich.ch/maps/rest/services/tiled95/LuftbildHybrid/MapServer?f=pjson -var layer_bounds = new OpenLayers.Bounds( +fixmystreet.maps.layer_bounds = new OpenLayers.Bounds( 2676000.9069999997, // W 1241399.842, // S 2689900.9069999997, // E 1254599.842); // N -var matrix_ids = [ +fixmystreet.maps.matrix_ids = [ // The two highest zoom levels are pretty much useless so they're disabled. // { // "matrixHeight": 882, @@ -184,7 +184,7 @@ fixmystreet.maps.config = function() { fixmystreet.controls.push( new OpenLayers.Control.PermalinkFMS('key-tool-problems-nearby', '/around') ); } - setup_wmts_base_map(); + this.setup_wmts_base_map(); fixmystreet.area_format = { fillColor: 'none', strokeWidth: 4, strokeColor: 'black' }; };