aboutsummaryrefslogtreecommitdiffstats
path: root/web/js
diff options
context:
space:
mode:
Diffstat (limited to 'web/js')
-rw-r--r--web/js/map-bing-ol.js33
-rw-r--r--web/js/southampton.js6
2 files changed, 32 insertions, 7 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"
});
diff --git a/web/js/southampton.js b/web/js/southampton.js
index af090d89b..ac7292f5d 100644
--- a/web/js/southampton.js
+++ b/web/js/southampton.js
@@ -120,7 +120,11 @@ $(function(){
$('#category_extra').hide('fast');
var lighting_content =
'<div id="street_light_report" style="margin: 1em 0em 1em 6.5em">Please report Street light problems using the Southampton Street Lighting site at: <a href="http://www.lightsoninsouthampton.co.uk/Public/ReportFault.aspx">http://www.lightsoninsouthampton.co.uk/Public/ReportFault.aspx</a></div>';
- $('#form_category_row').after(lighting_content);
+ if ( $('#form_category_row').count ) {
+ $('#form_category_row').after(lighting_content);
+ } else {
+ $('#form_category:parent').after(lighting_content);
+ }
} else {
$('#category_extra').hide('fast');
}