diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2019-02-01 12:14:12 +0000 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2019-02-04 18:31:50 +0000 |
commit | 457ce2af2b2e3d1e30ab440011b0c3de112b834b (patch) | |
tree | 4c722f96e4d94929404a20bf8d77555fd6f8582e /web/js | |
parent | d4c2211cfc5b69f2777039088d91fe423f1c7c29 (diff) |
Improve use of OL ArgParser/missing zoom in URL.
Remove the server-side zoom-in-url fix, instead use an ArgParser
subclass to default to the provided data if nothing in URL. Then
we can switch to using short lat/lon in geocoder URLs.
Diffstat (limited to 'web/js')
-rw-r--r-- | web/js/map-OpenLayers.js | 26 | ||||
-rw-r--r-- | web/js/map-OpenStreetMap.js | 2 | ||||
-rw-r--r-- | web/js/map-bing-ol.js | 2 | ||||
-rw-r--r-- | web/js/map-google-ol.js | 2 | ||||
-rw-r--r-- | web/js/map-streetview.js | 2 | ||||
-rw-r--r-- | web/js/map-toner-lite.js | 2 | ||||
-rw-r--r-- | web/js/map-wmts-bristol.js | 2 | ||||
-rw-r--r-- | web/js/map-wmts-zurich.js | 2 |
8 files changed, 24 insertions, 16 deletions
diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index e76ac439e..a18741049 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -831,15 +831,6 @@ $.extend(fixmystreet.utils, { fixmystreet.map.addLayer(layer); } - if (!fixmystreet.map.getCenter()) { - var centre = new OpenLayers.LonLat( fixmystreet.longitude, fixmystreet.latitude ); - centre.transform( - new OpenLayers.Projection("EPSG:4326"), - fixmystreet.map.getProjectionObject() - ); - fixmystreet.map.setCenter(centre, fixmystreet.zoom || 3); - } - // map.getCenter() returns a position in "map units", but sometimes you // want the center in GPS-style latitude/longitude coordinates (WGS84) // for example, to pass as GET params to fixmystreet.com/report/new. @@ -921,6 +912,23 @@ OpenLayers.Control.PanZoomFMS = OpenLayers.Class(OpenLayers.Control.PanZoom, { } }); +OpenLayers.Control.ArgParserFMS = OpenLayers.Class(OpenLayers.Control.ArgParser, { + getParameters: function(url) { + var args = OpenLayers.Control.ArgParser.prototype.getParameters.apply(this, arguments); + // Get defaults from provided data if not in URL + if (!args.lat && !args.lon) { + args.lon = fixmystreet.longitude; + args.lat = fixmystreet.latitude; + } + if (args.lat && !args.zoom) { + args.zoom = fixmystreet.zoom || 3; + } + return args; + }, + + CLASS_NAME: "OpenLayers.Control.ArgParserFMS" +}); + /* Overriding Permalink so that it can pass the correct zoom to OSM */ OpenLayers.Control.PermalinkFMS = OpenLayers.Class(OpenLayers.Control.Permalink, { _updateLink: function(alter_zoom) { diff --git a/web/js/map-OpenStreetMap.js b/web/js/map-OpenStreetMap.js index 4165f8ee4..52eb95493 100644 --- a/web/js/map-OpenStreetMap.js +++ b/web/js/map-OpenStreetMap.js @@ -4,7 +4,7 @@ fixmystreet.maps.config = function() { permalink_id = 'map_permalink'; } fixmystreet.controls = [ - new OpenLayers.Control.ArgParser(), + new OpenLayers.Control.ArgParserFMS(), new OpenLayers.Control.Attribution(), //new OpenLayers.Control.LayerSwitcher(), new OpenLayers.Control.Navigation(), diff --git a/web/js/map-bing-ol.js b/web/js/map-bing-ol.js index 526ad2da9..6c9ab8a62 100644 --- a/web/js/map-bing-ol.js +++ b/web/js/map-bing-ol.js @@ -6,7 +6,7 @@ fixmystreet.maps.config = function() { fixmystreet.controls = [ new OpenLayers.Control.Attribution(), - new OpenLayers.Control.ArgParser(), + new OpenLayers.Control.ArgParserFMS(), new OpenLayers.Control.Navigation(), new OpenLayers.Control.PermalinkFMS(permalink_id), new OpenLayers.Control.PanZoomFMS({id: 'fms_pan_zoom' }) diff --git a/web/js/map-google-ol.js b/web/js/map-google-ol.js index 99670d4f2..4b2d818c9 100644 --- a/web/js/map-google-ol.js +++ b/web/js/map-google-ol.js @@ -23,7 +23,7 @@ fixmystreet.maps.config = function() { } fixmystreet.controls = [ - new OpenLayers.Control.ArgParser(), + new OpenLayers.Control.ArgParserFMS(), new OpenLayers.Control.Navigation(), new OpenLayers.Control.PermalinkFMS(permalink_id), new OpenLayers.Control.PanZoomFMS({id: 'fms_pan_zoom' }) diff --git a/web/js/map-streetview.js b/web/js/map-streetview.js index 6d9195246..4701a7f20 100644 --- a/web/js/map-streetview.js +++ b/web/js/map-streetview.js @@ -1,6 +1,6 @@ fixmystreet.maps.config = function() { fixmystreet.controls = [ - new OpenLayers.Control.ArgParser(), + new OpenLayers.Control.ArgParserFMS(), new OpenLayers.Control.Navigation(), new OpenLayers.Control.Permalink(), new OpenLayers.Control.PanZoomFMS() diff --git a/web/js/map-toner-lite.js b/web/js/map-toner-lite.js index eda12ff28..0700dbb55 100644 --- a/web/js/map-toner-lite.js +++ b/web/js/map-toner-lite.js @@ -4,7 +4,7 @@ fixmystreet.maps.config = function() { permalink_id = 'map_permalink'; } fixmystreet.controls = [ - new OpenLayers.Control.ArgParser(), + new OpenLayers.Control.ArgParserFMS(), new OpenLayers.Control.Navigation(), new OpenLayers.Control.PermalinkFMS(permalink_id), new OpenLayers.Control.PanZoomFMS({id: 'fms_pan_zoom' }) diff --git a/web/js/map-wmts-bristol.js b/web/js/map-wmts-bristol.js index 35f5ed0d6..88db20c52 100644 --- a/web/js/map-wmts-bristol.js +++ b/web/js/map-wmts-bristol.js @@ -104,7 +104,7 @@ fixmystreet.maps.config = function() { } fixmystreet.controls = [ - new OpenLayers.Control.ArgParser(), + new OpenLayers.Control.ArgParserFMS(), new OpenLayers.Control.Navigation(), new OpenLayers.Control.PermalinkFMS(permalink_id) ]; diff --git a/web/js/map-wmts-zurich.js b/web/js/map-wmts-zurich.js index eda0fbf44..346e9b89a 100644 --- a/web/js/map-wmts-zurich.js +++ b/web/js/map-wmts-zurich.js @@ -135,7 +135,7 @@ fixmystreet.maps.config = function() { // This stuff is copied from js/map-bing-ol.js fixmystreet.controls = [ - new OpenLayers.Control.ArgParser(), + new OpenLayers.Control.ArgParserFMS(), new OpenLayers.Control.Navigation() ]; if ( fixmystreet.page != 'report' || !$('html').hasClass('mobile') ) { |