aboutsummaryrefslogtreecommitdiffstats
path: root/web/js
diff options
context:
space:
mode:
Diffstat (limited to 'web/js')
-rw-r--r--web/js/OpenLayers-2.13.1/theme/default/ie6-style.css10
-rw-r--r--web/js/OpenLayers-2.13.1/theme/default/ie6-style.tidy.css1
-rw-r--r--web/js/map-OpenLayers.js11
-rw-r--r--web/js/map-wmts-bristol.js176
4 files changed, 187 insertions, 11 deletions
diff --git a/web/js/OpenLayers-2.13.1/theme/default/ie6-style.css b/web/js/OpenLayers-2.13.1/theme/default/ie6-style.css
deleted file mode 100644
index a0fd7c639..000000000
--- a/web/js/OpenLayers-2.13.1/theme/default/ie6-style.css
+++ /dev/null
@@ -1,10 +0,0 @@
-.olControlZoomPanel div {
- background-image: url(img/zoom-panel-NOALPHA.png);
-}
-.olControlPanPanel div {
- background-image: url(img/pan-panel-NOALPHA.png);
-}
-.olControlEditingToolbar {
- width: 200px;
-}
-
diff --git a/web/js/OpenLayers-2.13.1/theme/default/ie6-style.tidy.css b/web/js/OpenLayers-2.13.1/theme/default/ie6-style.tidy.css
deleted file mode 100644
index 7a23bbc78..000000000
--- a/web/js/OpenLayers-2.13.1/theme/default/ie6-style.tidy.css
+++ /dev/null
@@ -1 +0,0 @@
-.olControlZoomPanel div{background-image:url(img/zoom-panel-NOALPHA.png);}.olControlPanPanel div{background-image:url(img/pan-panel-NOALPHA.png);}.olControlEditingToolbar{width:200px;} \ No newline at end of file
diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js
index f5f5f2934..1379d0fa5 100644
--- a/web/js/map-OpenLayers.js
+++ b/web/js/map-OpenLayers.js
@@ -643,6 +643,17 @@ OpenLayers.Protocol.FixMyStreet = OpenLayers.Class(OpenLayers.Protocol.HTTP, {
/* Pan data handler */
OpenLayers.Format.FixMyStreet = OpenLayers.Class(OpenLayers.Format.JSON, {
read: function(json, filter) {
+ // Check we haven't received the data after the map has been clicked.
+ if (fixmystreet.page == 'new') {
+ // If we have, we want to do nothing, which means returning an
+ // array of the back-projected version of the current pin
+ var pin = fixmystreet.markers.features[0].clone();
+ pin.geometry.transform(
+ fixmystreet.map.getProjectionObject(),
+ new OpenLayers.Projection("EPSG:4326")
+ );
+ return [ pin ];
+ }
if (typeof json == 'string') {
obj = OpenLayers.Format.JSON.prototype.read.apply(this, [json, filter]);
} else {
diff --git a/web/js/map-wmts-bristol.js b/web/js/map-wmts-bristol.js
new file mode 100644
index 000000000..a1889beed
--- /dev/null
+++ b/web/js/map-wmts-bristol.js
@@ -0,0 +1,176 @@
+/*
+ * Maps for FMS using Bristol City Council's WMTS tile server
+ */
+
+// 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(
+ 268756.31099999975, // W
+ 98527.70309999958, // S
+ 385799.51099999994, // E
+ 202566.10309999995); // N
+
+var matrix_ids = [
+ {
+ "identifier": "0",
+ "supportedCRS": "urn:ogc:def:crs:EPSG::27700",
+ "scaleDenominator": 181428.9342864172,
+ "tileWidth": 256,
+ "tileHeight": 256,
+ "matrixWidth": 432,
+ "matrixHeight": 337
+ },
+ {
+ "identifier": "1",
+ "supportedCRS": "urn:ogc:def:crs:EPSG::27700",
+ "scaleDenominator": 90714.4671432086,
+ "tileWidth": 256,
+ "tileHeight": 256,
+ "matrixWidth": 863,
+ "matrixHeight": 673
+ },
+ {
+ "identifier": "2",
+ "supportedCRS": "urn:ogc:def:crs:EPSG::27700",
+ "scaleDenominator": 45357.2335716043,
+ "tileWidth": 256,
+ "tileHeight": 256,
+ "matrixWidth": 1725,
+ "matrixHeight": 1345
+ },
+ {
+ "identifier": "3",
+ "supportedCRS": "urn:ogc:def:crs:EPSG::27700",
+ "scaleDenominator": 22678.61678580215,
+ "tileWidth": 256,
+ "tileHeight": 256,
+ "matrixWidth": 3449,
+ "matrixHeight": 2690
+ },
+ {
+ "identifier": "4",
+ "supportedCRS": "urn:ogc:def:crs:EPSG::27700",
+ "scaleDenominator": 11339.308392901075,
+ "tileWidth": 256,
+ "tileHeight": 256,
+ "matrixWidth": 6898,
+ "matrixHeight": 5379
+ },
+ {
+ "identifier": "5",
+ "supportedCRS": "urn:ogc:def:crs:EPSG::27700",
+ "scaleDenominator": 5669.654196450538,
+ "tileWidth": 256,
+ "tileHeight": 256,
+ "matrixWidth": 13795,
+ "matrixHeight": 10758
+ },
+ {
+ "identifier": "6",
+ "supportedCRS": "urn:ogc:def:crs:EPSG::27700",
+ "scaleDenominator": 2834.827098225269,
+ "tileWidth": 256,
+ "tileHeight": 256,
+ "matrixWidth": 27590,
+ "matrixHeight": 21515
+ },
+ {
+ "identifier": "7",
+ "supportedCRS": "urn:ogc:def:crs:EPSG::27700",
+ "scaleDenominator": 1181.177957593862,
+ "tileWidth": 256,
+ "tileHeight": 256,
+ "matrixWidth": 66215,
+ "matrixHeight": 51634
+ },
+ {
+ "identifier": "8",
+ "supportedCRS": "urn:ogc:def:crs:EPSG::27700",
+ "scaleDenominator": 708.7067745563172,
+ "tileWidth": 256,
+ "tileHeight": 256,
+ "matrixWidth": 110359,
+ "matrixHeight": 86057
+ }
+];
+
+/*
+ * set_map_config() is called on dom ready in map-OpenLayers.js
+ * to setup the way the map should operate.
+ */
+ function set_map_config(perm) {
+ // This stuff is copied from js/map-bing-ol.js
+
+ 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.ArgParser(),
+ fixmystreet.nav_control
+ ];
+ if ( fixmystreet.page != 'report' || !$('html').hasClass('mobile') ) {
+ fixmystreet.controls.push( 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') );
+ }
+
+ 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,
+ units: 'm',
+ scales: fixmystreet.wmts_config.scales
+ };
+
+ fixmystreet.layer_options = [{
+ projection: new OpenLayers.Projection(fixmystreet.wmts_config.map_projection),
+ name: fixmystreet.wmts_config.layer_name,
+ layer: fixmystreet.wmts_config.layer_name,
+ formatSuffix: fixmystreet.wmts_config.tile_suffix.replace(".", ""),
+ matrixSet: fixmystreet.wmts_config.matrix_set,
+ requestEncoding: "REST",
+ url: fixmystreet.wmts_config.tile_url,
+ style: fixmystreet.wmts_config.layer_style,
+ matrixIds: matrix_ids,
+ 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"
+});
+
+function fms_marker_size_for_zoom(zoom) {
+ if (zoom >= 7) {
+ return 'normal';
+ } else if (zoom >= 4) {
+ return 'small';
+ } else {
+ return 'mini';
+ }
+}