diff options
author | Struan Donald <struan@exo.org.uk> | 2012-08-22 10:57:10 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2012-08-22 10:57:10 +0100 |
commit | 2e0a4e8ec45579e4e5c9cf8aa123d5ab215b9703 (patch) | |
tree | c13e3c59b686e01460dc7960547f7e9c53c288bd /web/js/map-bing-ol.js | |
parent | b99c5ff97b29a27eeba52ed24385ac30388e875c (diff) | |
parent | 88a7d38dffa3dabdf0f85573b254cea9c8ab232b (diff) |
Merge remote-tracking branch 'origin/master' into fmb-read-only
Conflicts:
.gitignore
bin/make_css
conf/general.yml-example
perllib/FixMyStreet/App/Controller/Council.pm
perllib/FixMyStreet/App/Controller/Report/New.pm
perllib/FixMyStreet/Cobrand/Default.pm
templates/web/default/around/around_index.html
templates/web/default/index.html
templates/web/emptyhomes/index.html
templates/web/fixmystreet/around/around_index.html
templates/web/fixmystreet/index.html
web/fixmystreet_app_cgi.cgi
web/fixmystreet_app_fastcgi.cgi
Diffstat (limited to 'web/js/map-bing-ol.js')
-rw-r--r-- | web/js/map-bing-ol.js | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/web/js/map-bing-ol.js b/web/js/map-bing-ol.js index 7d40f8afc..6d86663f0 100644 --- a/web/js/map-bing-ol.js +++ b/web/js/map-bing-ol.js @@ -22,12 +22,30 @@ function set_map_config(perm) { if (fixmystreet.map_type) { tile_base = fixmystreet.map_type; } - fixmystreet.map_type = OpenLayers.Layer.Bing; + fixmystreet.map_type = OpenLayers.Layer.BingUK; } -OpenLayers.Layer.Bing = OpenLayers.Class(OpenLayers.Layer.XYZ, { +OpenLayers.Layer.BingUK = OpenLayers.Class(OpenLayers.Layer.XYZ, { attributionTemplate: '${logo}${copyrights}', + uk_bounds: [ + new OpenLayers.Bounds(-6.6, 49.8, 1.102680, 51), + new OpenLayers.Bounds(-5.4, 51, 2.28, 54.94), + new OpenLayers.Bounds(-5.85, 54.94, -1.15, 55.33), + new OpenLayers.Bounds(-9.35, 55.33, -0.7, 60.98) + ], + in_uk: function(c) { + c = c.clone(); + c.transform( + fixmystreet.map.getProjectionObject(), + new OpenLayers.Projection("EPSG:4326") + ); + if ( this.uk_bounds[0].contains(c.lon, c.lat) || this.uk_bounds[1].contains(c.lon, c.lat) || this.uk_bounds[2].contains(c.lon, c.lat) || this.uk_bounds[3].contains(c.lon, c.lat) ) { + return true; + } + return false; + }, + setMap: function() { OpenLayers.Layer.XYZ.prototype.setMap.apply(this, arguments); this.updateAttribution(); @@ -38,7 +56,9 @@ OpenLayers.Layer.Bing = OpenLayers.Class(OpenLayers.Layer.XYZ, { var z = this.map.getZoom() + this.zoomOffset; var copyrights; var logo = ''; - if (z >= 16) { + var c = this.map.getCenter(); + var in_uk = c ? this.in_uk(c) : true; + if (z >= 16 && in_uk) { copyrights = 'Contains Ordnance Survey data © Crown copyright and database right 2010'; } else { logo = '<a href="http://www.bing.com/maps/"><img border=0 src="//dev.virtualearth.net/Branding/logo_powered_by.png"></a>'; @@ -98,14 +118,15 @@ OpenLayers.Layer.Bing = OpenLayers.Class(OpenLayers.Layer.XYZ, { this.map.getZoom() + this.zoomOffset; var url; - if (z >= 16) { + var in_uk = this.in_uk(bounds.getCenterLonLat()); + if (z >= 16 && in_uk) { url = []; for (var i=0; i< tile_base[0].length; i++) { url.push( tile_base[1].replace('{S}', tile_base[0][i]) + "/${z}/${x}/${y}.png" ); } } else { var type = ''; - if (z > 10) { type = '&productSet=mmOS'; } + if (z > 10 && in_uk) { type = '&productSet=mmOS'; } url = [ "//ecn.t0.tiles.virtualearth.net/tiles/r${id}.png?g=701" + type, "//ecn.t1.tiles.virtualearth.net/tiles/r${id}.png?g=701" + type, @@ -121,5 +142,5 @@ OpenLayers.Layer.Bing = OpenLayers.Class(OpenLayers.Layer.XYZ, { return path; }, - CLASS_NAME: "OpenLayers.Layer.Bing" + CLASS_NAME: "OpenLayers.Layer.BingUK" }); |