1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
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
}
];
/*
* maps.config() is called on dom ready in map-OpenLayers.js
* to setup the way the map should operate.
*/
fixmystreet.maps.config = function() {
// 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"
});
fixmystreet.maps.marker_size_for_zoom = function(zoom) {
if (zoom >= 7) {
return 'normal';
} else if (zoom >= 4) {
return 'small';
} else {
return 'mini';
}
};
|