aboutsummaryrefslogtreecommitdiffstats
path: root/web/js/map-wmts-zurich.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-zurich.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-zurich.js')
-rw-r--r--web/js/map-wmts-zurich.js313
1 files changed, 121 insertions, 192 deletions
diff --git a/web/js/map-wmts-zurich.js b/web/js/map-wmts-zurich.js
index 9e0555079..aa673f52d 100644
--- a/web/js/map-wmts-zurich.js
+++ b/web/js/map-wmts-zurich.js
@@ -2,6 +2,117 @@
* Maps for FMZ using Zurich council's WMTS tile server
*/
+// From 'fullExtent' from http://www.gis.stadt-zuerich.ch/maps/rest/services/tiled95/LuftbildHybrid/MapServer?f=pjson
+var layer_bounds = new OpenLayers.Bounds(
+ 2676000.9069999997, // W
+ 1241399.842, // S
+ 2689900.9069999997, // E
+ 1254599.842); // N
+
+var matrix_ids = [
+ // The two highest zoom levels are pretty much useless so they're disabled.
+ // {
+ // "matrixHeight": 882,
+ // "scaleDenominator": 241905.24571522293,
+ // "identifier": "0",
+ // "tileWidth": 512,
+ // "supportedCRS": "urn:ogc:def:crs:EPSG::2056",
+ // "tileHeight": 512,
+ // "matrixWidth": 868
+ // },
+ // {
+ // "matrixHeight": 1764,
+ // "scaleDenominator": 120952.62285761147,
+ // "identifier": "1",
+ // "tileWidth": 512,
+ // "supportedCRS": "urn:ogc:def:crs:EPSG::2056",
+ // "tileHeight": 512,
+ // "matrixWidth": 1735
+ // },
+
+ {
+ "matrixHeight": 3527,
+ "scaleDenominator": 60476.31142880573,
+ "identifier": "2",
+ "tileWidth": 512,
+ "supportedCRS": "urn:ogc:def:crs:EPSG::2056",
+ "tileHeight": 512,
+ "matrixWidth": 3470
+ },
+ {
+ "matrixHeight": 7053,
+ "scaleDenominator": 30238.155714402867,
+ "identifier": "3",
+ "tileWidth": 512,
+ "supportedCRS": "urn:ogc:def:crs:EPSG::2056",
+ "tileHeight": 512,
+ "matrixWidth": 6939
+ },
+ {
+ "matrixHeight": 14106,
+ "scaleDenominator": 15119.077857201433,
+ "identifier": "4",
+ "tileWidth": 512,
+ "supportedCRS": "urn:ogc:def:crs:EPSG::2056",
+ "tileHeight": 512,
+ "matrixWidth": 13877
+ },
+ {
+ "matrixHeight": 28211,
+ "scaleDenominator": 7559.538928600717,
+ "identifier": "5",
+ "tileWidth": 512,
+ "supportedCRS": "urn:ogc:def:crs:EPSG::2056",
+ "tileHeight": 512,
+ "matrixWidth": 27753
+ },
+ {
+ "matrixHeight": 56422,
+ "scaleDenominator": 3779.7694643003583,
+ "identifier": "6",
+ "tileWidth": 512,
+ "supportedCRS": "urn:ogc:def:crs:EPSG::2056",
+ "tileHeight": 512,
+ "matrixWidth": 55505
+ },
+ {
+ "matrixHeight": 112844,
+ "scaleDenominator": 1889.8847321501792,
+ "identifier": "7",
+ "tileWidth": 512,
+ "supportedCRS": "urn:ogc:def:crs:EPSG::2056",
+ "tileHeight": 512,
+ "matrixWidth": 111010
+ },
+ {
+ "matrixHeight": 225687,
+ "scaleDenominator": 944.9423660750896,
+ "identifier": "8",
+ "tileWidth": 512,
+ "supportedCRS": "urn:ogc:def:crs:EPSG::2056",
+ "tileHeight": 512,
+ "matrixWidth": 222020
+ },
+ {
+ "matrixHeight": 451374,
+ "scaleDenominator": 472.4711830375448,
+ "identifier": "9",
+ "tileWidth": 512,
+ "supportedCRS": "urn:ogc:def:crs:EPSG::2056",
+ "tileHeight": 512,
+ "matrixWidth": 444039
+ },
+ {
+ "matrixHeight": 902748,
+ "scaleDenominator": 236.2355915187724,
+ "identifier": "10",
+ "tileWidth": 512,
+ "supportedCRS": "urn:ogc:def:crs:EPSG::2056",
+ "tileHeight": 512,
+ "matrixWidth": 888078
+ }
+];
+
function fixmystreet_zurich_admin_drag() {
var admin_drag = new OpenLayers.Control.DragFeature( fixmystreet.markers, {
onComplete: function(feature, e) {
@@ -69,199 +180,17 @@ $(function(){
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 = 96;
-
- fixmystreet.map_options = {
- maxExtent: new OpenLayers.Bounds(676000, 241402, 689896, 254596),
- units: 'm',
- scales: [ '64000', '32000', '16000', '8000', '4000', '2000', '1000', '500', '250' ]
- };
-
- var layer_options = {
- projection: new OpenLayers.Projection("EPSG:21781"),
- name: "tiled_LuftbildHybrid",
- layer: "tiled_LuftbildHybrid",
- matrixSet: "default028mm",
- requestEncoding: "REST",
- url: "//www.gis.stadt-zuerich.ch/maps/rest/services/tiled/LuftbildHybrid/MapServer/WMTS/tile/",
- style: "default",
- matrixIds: [
- // {
- // "identifier": "0",
- // "matrixHeight": 903,
- // "matrixWidth": 889,
- // "scaleDenominator": 236235.59151877242,
- // "supportedCRS": "urn:ogc:def:crs:EPSG::21781",
- // "tileHeight": 512,
- // "tileWidth": 512,
- // "topLeftCorner": {
- // "lat": 30814423,
- // "lon": -29386322
- // }
- // },
- // {
- // "identifier": "1",
- // "matrixHeight": 1806,
- // "matrixWidth": 1777,
- // "scaleDenominator": 118117.79575938621,
- // "supportedCRS": "urn:ogc:def:crs:EPSG::21781",
- // "tileHeight": 512,
- // "tileWidth": 512,
- // "topLeftCorner": {
- // "lat": 30814423,
- // "lon": -29386322
- // }
- // },
- {
- "identifier": "2",
- "matrixHeight": 3527,
- "matrixWidth": 3470,
- "scaleDenominator": 60476.31142880573,
- "supportedCRS": "urn:ogc:def:crs:EPSG::21781",
- "tileHeight": 512,
- "tileWidth": 512,
- "topLeftCorner": {
- "lat": 30814423,
- "lon": -29386322
- }
- },
- {
- "identifier": "3",
- "matrixHeight": 7053,
- "matrixWidth": 6939,
- "scaleDenominator": 30238.155714402867,
- "supportedCRS": "urn:ogc:def:crs:EPSG::21781",
- "tileHeight": 512,
- "tileWidth": 512,
- "topLeftCorner": {
- "lat": 30814423,
- "lon": -29386322
- }
- },
- {
- "identifier": "4",
- "matrixHeight": 14106,
- "matrixWidth": 13877,
- "scaleDenominator": 15119.077857201433,
- "supportedCRS": "urn:ogc:def:crs:EPSG::21781",
- "tileHeight": 512,
- "tileWidth": 512,
- "topLeftCorner": {
- "lat": 30814423,
- "lon": -29386322
- }
- },
- {
- "identifier": "5",
- "matrixHeight": 28211,
- "matrixWidth": 27753,
- "scaleDenominator": 7559.538928600717,
- "supportedCRS": "urn:ogc:def:crs:EPSG::21781",
- "tileHeight": 512,
- "tileWidth": 512,
- "topLeftCorner": {
- "lat": 30814423,
- "lon": -29386322
- }
- },
- {
- "identifier": "6",
- "matrixHeight": 56422,
- "matrixWidth": 55505,
- "scaleDenominator": 3779.7694643003583,
- "supportedCRS": "urn:ogc:def:crs:EPSG::21781",
- "tileHeight": 512,
- "tileWidth": 512,
- "topLeftCorner": {
- "lat": 30814423,
- "lon": -29386322
- }
- },
- {
- "identifier": "7",
- "matrixHeight": 112844,
- "matrixWidth": 111010,
- "scaleDenominator": 1889.8847321501792,
- "supportedCRS": "urn:ogc:def:crs:EPSG::21781",
- "tileHeight": 512,
- "tileWidth": 512,
- "topLeftCorner": {
- "lat": 30814423,
- "lon": -29386322
- }
- },
- {
- "identifier": "8",
- "matrixHeight": 225687,
- "matrixWidth": 222020,
- "scaleDenominator": 944.9423660750896,
- "supportedCRS": "urn:ogc:def:crs:EPSG::21781",
- "tileHeight": 512,
- "tileWidth": 512,
- "topLeftCorner": {
- "lat": 30814423,
- "lon": -29386322
- }
- },
- {
- "identifier": "9",
- "matrixHeight": 451374,
- "matrixWidth": 444039,
- "scaleDenominator": 472.4711830375448,
- "supportedCRS": "urn:ogc:def:crs:EPSG::21781",
- "tileHeight": 512,
- "tileWidth": 512,
- "topLeftCorner": {
- "lat": 30814423,
- "lon": -29386322
- }
- },
- {
- "identifier": "10",
- "matrixHeight": 902748,
- "matrixWidth": 888078,
- "scaleDenominator": 236.2355915187724,
- "supportedCRS": "urn:ogc:def:crs:EPSG::21781",
- "tileHeight": 512,
- "tileWidth": 512,
- "topLeftCorner": {
- "lat": 30814423,
- "lon": -29386322
- }
- }
- ]
- };
- fixmystreet.layer_options = [
- layer_options, OpenLayers.Util.applyDefaults({
- name: "Stadtplan3D",
- layer: "Stadtplan3D",
- url: "//www.gis.stadt-zuerich.ch/maps/rest/services/tiled/Stadtplan3D/MapServer/WMTS/tile/"
- }, layer_options)
- ];
-
- // Give main code a new bbox_strategy that translates between
- // lat/lon and our swiss coordinates
- fixmystreet.bbox_strategy = new OpenLayers.Strategy.ZurichBBOX({ratio: 1});
+ setup_wmts_base_map();
fixmystreet.area_format = { fillColor: 'none', strokeWidth: 4, strokeColor: 'black' };
}
-OpenLayers.Strategy.ZurichBBOX = OpenLayers.Class(OpenLayers.Strategy.BBOX, {
- getMapBounds: function() {
- // Get the map bounds but return them in lat/lon, not
- // Swiss coordinates
- if (this.layer.map === null) {
- return null;
- }
-
- var swissBounds = this.layer.map.getExtent();
- // Transform bound corners into WGS84
- swissBounds.transform( new OpenLayers.Projection("EPSG:21781"), new OpenLayers.Projection("EPSG:4326") );
- return swissBounds;
- },
-
- CLASS_NAME: "OpenLayers.Strategy.ZurichBBOX"
-});
+function fms_marker_size_for_zoom(zoom) {
+ if (zoom >= 6) {
+ return 'normal';
+ } else if (zoom >= 3) {
+ return 'small';
+ } else {
+ return 'mini';
+ }
+}