diff options
Diffstat (limited to 'web/js')
-rw-r--r-- | web/js/map-OpenLayers.js | 17 | ||||
-rw-r--r-- | web/js/map-wmts-base.js | 23 | ||||
-rw-r--r-- | web/js/map-wmts-isleofwight.js | 206 |
3 files changed, 222 insertions, 24 deletions
diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index cd2283491..1588bda2e 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -562,6 +562,9 @@ $.extend(fixmystreet.utils, { } else { $.extend(style.defaultStyle, { fillColor: 'black', strokeColor: 'black' }); } + if (!this.features.length) { + return; + } var geometry = this.features[0].geometry; if (geometry.CLASS_NAME == 'OpenLayers.Geometry.Collection' || geometry.CLASS_NAME == 'OpenLayers.Geometry.MultiPolygon') { @@ -673,7 +676,7 @@ $.extend(fixmystreet.utils, { styleMap: pin_layer_style_map }; if (fixmystreet.page == 'around') { - fixmystreet.bbox_strategy = fixmystreet.bbox_strategy || new OpenLayers.Strategy.FixMyStreet(); + fixmystreet.bbox_strategy = fixmystreet.map_bbox_strategy || new OpenLayers.Strategy.FixMyStreet(); pin_layer_options.strategies = [ fixmystreet.bbox_strategy ]; } if (fixmystreet.page == 'reports') { @@ -1185,3 +1188,15 @@ OpenLayers.Renderer.SVGBig = OpenLayers.Class(OpenLayers.Renderer.SVG, { CLASS_NAME: "OpenLayers.Renderer.SVGBig" }); + +/* Stop sending a needless header so that no preflight CORS request */ +OpenLayers.Request.XMLHttpRequest.prototype.setRequestHeader = function(sName, sValue) { + if (sName.toLowerCase() == 'x-requested-with') { + return; + } + if (!this._headers) { + this._headers = {}; + } + this._headers[sName] = sValue; + return this._object.setRequestHeader(sName, sValue); +}; diff --git a/web/js/map-wmts-base.js b/web/js/map-wmts-base.js index fe8d8015e..43f829ab5 100644 --- a/web/js/map-wmts-base.js +++ b/web/js/map-wmts-base.js @@ -28,27 +28,4 @@ fixmystreet.maps.setup_wmts_base_map = function() { tileOrigin: new OpenLayers.LonLat(fixmystreet.wmts_config.origin_x, fixmystreet.wmts_config.origin_y) }); }); - - // Give main code a new bbox_strategy that translates between - // lat/lon and our WMTS layer's coordinates - fixmystreet.bbox_strategy = new OpenLayers.Strategy.ReprojectBBOX({ - ratio: 1 - }); }; - -OpenLayers.Strategy.ReprojectBBOX = OpenLayers.Class(OpenLayers.Strategy.BBOX, { - getMapBounds: function() { - // Get the map bounds but return them in lat/lon, not - // local coordinates - if (this.layer.map === null) { - return null; - } - - var localBounds = this.layer.map.getExtent(); - // Transform bound corners into WGS84 - localBounds.transform( new OpenLayers.Projection(fixmystreet.wmts_config.map_projection), new OpenLayers.Projection("EPSG:4326") ); - return localBounds; - }, - - CLASS_NAME: "OpenLayers.Strategy.ReprojectBBOX" -}); diff --git a/web/js/map-wmts-isleofwight.js b/web/js/map-wmts-isleofwight.js new file mode 100644 index 000000000..464bee913 --- /dev/null +++ b/web/js/map-wmts-isleofwight.js @@ -0,0 +1,206 @@ +/* + * Maps for FMS using Island Roads' WMTS tile server + */ + +fixmystreet.maps.layer_bounds = new OpenLayers.Bounds( + 428576.1131782566, + 70608.46901095579, + 468137.51522498735, + 101069.6062942903 +); + +fixmystreet.maps.matrix_ids = [ + // The first 5 levels don't load and are really zoomed-out, so + // they're not included here. + //{ + //"identifier": 0, + //"scaleDenominator": 566965.4196450538, + //"supportedCRS": "urn:ogc:def:crs:EPSG:27700", + //"tileWidth": 256, + //"tileHeight": 256, + //"matrixWidth": 140, + //"matrixHeight": 109 + //}, + //{ + //"identifier": 1, + //"scaleDenominator": 472471.18303754483, + //"supportedCRS": "urn:ogc:def:crs:EPSG:27700", + //"tileWidth": 256, + //"tileHeight": 256, + //"matrixWidth": 168, + //"matrixHeight": 130 + //}, + //{ + //"identifier": 2, + //"scaleDenominator": 377976.9464300358, + //"supportedCRS": "urn:ogc:def:crs:EPSG:27700", + //"tileWidth": 256, + //"tileHeight": 256, + //"matrixWidth": 210, + //"matrixHeight": 163 + //}, + //{ + //"identifier": 3, + //"scaleDenominator": 283482.7098225269, + //"supportedCRS": "urn:ogc:def:crs:EPSG:27700", + //"tileWidth": 256, + //"tileHeight": 256, + //"matrixWidth": 280, + //"matrixHeight": 217 + //}, + //{ + //"identifier": 4, + //"scaleDenominator": 188988.4732150179, + //"supportedCRS": "urn:ogc:def:crs:EPSG:27700", + //"tileWidth": 256, + //"tileHeight": 256, + //"matrixWidth": 420, + //"matrixHeight": 325 + //}, + { + "identifier": 5, + "scaleDenominator": 94494.23660750895, + "supportedCRS": "urn:ogc:def:crs:EPSG:27700", + "tileWidth": 256, + "tileHeight": 256, + "matrixWidth": 840, + "matrixHeight": 650 + }, + { + "identifier": 6, + "scaleDenominator": 70870.67745563173, + "supportedCRS": "urn:ogc:def:crs:EPSG:27700", + "tileWidth": 256, + "tileHeight": 256, + "matrixWidth": 1120, + "matrixHeight": 867 + }, + { + "identifier": 7, + "scaleDenominator": 47247.118303754476, + "supportedCRS": "urn:ogc:def:crs:EPSG:27700", + "tileWidth": 256, + "tileHeight": 256, + "matrixWidth": 1680, + "matrixHeight": 1300 + }, + { + "identifier": 8, + "scaleDenominator": 23623.559151877238, + "supportedCRS": "urn:ogc:def:crs:EPSG:27700", + "tileWidth": 256, + "tileHeight": 256, + "matrixWidth": 3360, + "matrixHeight": 2599 + }, + { + "identifier": 9, + "scaleDenominator": 9449.423660750896, + "supportedCRS": "urn:ogc:def:crs:EPSG:27700", + "tileWidth": 256, + "tileHeight": 256, + "matrixWidth": 8399, + "matrixHeight": 6496 + }, + { + "identifier": 10, + "scaleDenominator": 7559.538928600717, + "supportedCRS": "urn:ogc:def:crs:EPSG:27700", + "tileWidth": 256, + "tileHeight": 256, + "matrixWidth": 10499, + "matrixHeight": 8120 + }, + { + "identifier": 11, + "scaleDenominator": 5669.654196450538, + "supportedCRS": "urn:ogc:def:crs:EPSG:27700", + "tileWidth": 256, + "tileHeight": 256, + "matrixWidth": 13998, + "matrixHeight": 10826 + }, + { + "identifier": 12, + "scaleDenominator": 3779.7694643003583, + "supportedCRS": "urn:ogc:def:crs:EPSG:27700", + "tileWidth": 256, + "tileHeight": 256, + "matrixWidth": 20997, + "matrixHeight": 16239 + }, + { + "identifier": 13, + "scaleDenominator": 1889.8847321501792, + "supportedCRS": "urn:ogc:def:crs:EPSG:27700", + "tileWidth": 256, + "tileHeight": 256, + "matrixWidth": 41993, + "matrixHeight": 32478 + }, + { + "identifier": 14, + "scaleDenominator": 944.9423660750896, + "supportedCRS": "urn:ogc:def:crs:EPSG:27700", + "tileWidth": 256, + "tileHeight": 256, + "matrixWidth": 83985, + "matrixHeight": 64955 + }, + { + "identifier": 15, + "scaleDenominator": 377.9769464300358, + "supportedCRS": "urn:ogc:def:crs:EPSG:27700", + "tileWidth": 256, + "tileHeight": 256, + "matrixWidth": 209961, + "matrixHeight": 162387 + } +]; + +/* + * maps.config() is called on dom ready in map-OpenLayers.js + * to setup the way the map should operate. + */ +fixmystreet.maps.config = function() { + var permalink_id; + if ($('#map_permalink').length) { + permalink_id = 'map_permalink'; + } + + fixmystreet.controls = [ + new OpenLayers.Control.ArgParserFMS(), + new OpenLayers.Control.Navigation(), + new OpenLayers.Control.PermalinkFMS(permalink_id), + new OpenLayers.Control.PanZoomFMS({id: 'fms_pan_zoom' }) + ]; + + /* Linking back to around from report page, keeping track of map moves */ + if ( fixmystreet.page == 'report' ) { + fixmystreet.controls.push( new OpenLayers.Control.PermalinkFMS('key-tool-problems-nearby', '/around') ); + } + + this.setup_wmts_base_map(); +}; + +fixmystreet.maps.marker_size = function() { + var zoom = fixmystreet.map.getZoom() + fixmystreet.zoomOffset; + if (zoom >= 7) { + return 'normal'; + } else if (zoom >= 4) { + return 'small'; + } else { + return 'mini'; + } +}; + +fixmystreet.maps.selected_marker_size = function() { + var zoom = fixmystreet.map.getZoom() + fixmystreet.zoomOffset; + if (zoom >= 7) { + return 'big'; + } else if (zoom >= 4) { + return 'normal'; + } else { + return 'small'; + } +}; |