aboutsummaryrefslogtreecommitdiffstats
path: root/web/js/map-wmts-base.js
diff options
context:
space:
mode:
authorDave Arter <davea@mysociety.org>2016-06-29 11:07:36 +0100
committerDave Arter <davea@mysociety.org>2016-07-07 11:28:33 +0100
commit5b9670512542f54588cc89f2eefc943db26b9ee2 (patch)
treeb929b12826b3a916e68003559a222bd62f4ac53f /web/js/map-wmts-base.js
parent6d3cbb5d58c0297959c541da50faaf39884ffe1c (diff)
[Zurich] Use new LV95/CH1903+ geocoder and base map tiles
- Use new `getLocation95` method for geocoding addresses - Replace Coordinates::CH1903 with Coordinates::CH1903Plus - Refactor Map::Zurich to use WMTSBase instead of duplicating code - Slightly refactor map templates to make using custom WMTS tiles easier - Use correct sizes for marker pins on maps Closes mysociety/FixMyStreet-Commercial#769. Closes mysociety/FixMyStreet-Commercial#768.
Diffstat (limited to 'web/js/map-wmts-base.js')
-rw-r--r--web/js/map-wmts-base.js56
1 files changed, 56 insertions, 0 deletions
diff --git a/web/js/map-wmts-base.js b/web/js/map-wmts-base.js
new file mode 100644
index 000000000..c60afe4e1
--- /dev/null
+++ b/web/js/map-wmts-base.js
@@ -0,0 +1,56 @@
+// Functionality required by all OpenLayers WMTS base maps
+
+function setup_wmts_base_map() {
+ 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 = [];
+ fixmystreet.wmts_config.layer_names.forEach(function(v, i) {
+ 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],
+ 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,
+ 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"
+});
+
+
+// \ No newline at end of file