diff options
Diffstat (limited to 'web/js')
-rw-r--r-- | web/js/fixmystreet-admin.js | 50 | ||||
-rw-r--r-- | web/js/fixmystreet.js | 4 | ||||
-rw-r--r-- | web/js/jquery.fixedthead.js | 81 | ||||
-rw-r--r-- | web/js/map-OpenLayers.js | 125 | ||||
-rw-r--r-- | web/js/map-OpenStreetMap.js | 1 | ||||
-rw-r--r-- | web/js/map-bing-ol.js | 82 | ||||
-rw-r--r-- | web/js/map-fms.js | 76 | ||||
-rw-r--r-- | web/js/map-google-ol.js | 8 | ||||
-rw-r--r-- | web/js/map-streetview.js | 4 | ||||
-rw-r--r-- | web/js/map-toner-lite.js | 19 | ||||
-rw-r--r-- | web/js/map-wmts-zurich.js | 1 |
11 files changed, 345 insertions, 106 deletions
diff --git a/web/js/fixmystreet-admin.js b/web/js/fixmystreet-admin.js index 1663dda7b..5e0d873c5 100644 --- a/web/js/fixmystreet-admin.js +++ b/web/js/fixmystreet-admin.js @@ -3,13 +3,13 @@ $(function(){ // hide the open311_only section and reveal it only when send_method is relevant var $open311_only = $('.admin-open311-only'); - + function hide_or_show_open311(hide_fast) { var send_method = $('#send_method').val(); var show_open311 = false; if ($('#endpoint').val()) { show_open311 = true; // always show the form if there is an endpoint value - } else if (send_method && send_method.toLowerCase() != 'email') { + } else if (send_method && !send_method.match(/^(email|emptyhomes|noop|refused)$/i)) { show_open311 = true; } if (show_open311) { @@ -28,34 +28,32 @@ $(function(){ hide_or_show_open311(true); } - if ($('body').hasClass("show-admin-notes")) { - // admin hints: maybe better implemented as tooltips? - $(".admin-hint").on('click', function(){ - if ($(this).hasClass('admin-hint-show')) { - $(this).removeClass('admin-hint-show'); + // admin hints: maybe better implemented as tooltips? + $(".admin-hint").on('click', function(){ + if ($(this).hasClass('admin-hint-show')) { + $(this).removeClass('admin-hint-show'); + } else { + $(this).addClass('admin-hint-show'); + } + }); + + // on a body's page, hide/show deleted contact categories + var $table_with_deleted_contacts = $('table tr.is-deleted td.contact-category').closest('table'); + if ($table_with_deleted_contacts.length == 1) { + var $toggle_deleted_btn = $("<input type='submit' class='btn' value='Hide deleted contacts' id='toggle-deleted-contacts-btn' style='margin:1em 0;'/>"); + $table_with_deleted_contacts.before($toggle_deleted_btn); + $toggle_deleted_btn.on('click', function(e){ + e.preventDefault(); + var $cols = $table_with_deleted_contacts.find('tr.is-deleted'); + if ($cols.first().is(':visible')) { + $cols.hide(); + $(this).prop("value", 'Show deleted contacts'); } else { - $(this).addClass('admin-hint-show'); + $cols.show(); + $(this).prop("value", 'Hide deleted contacts'); } }); - - // on a body's page, hide/show deleted contact categories - var $table_with_deleted_contacts = $('table tr.is-deleted td.contact-category').closest('table'); - if ($table_with_deleted_contacts.length == 1) { - var $toggle_deleted_btn = $("<input type='submit' class='btn' value='Hide deleted contacts' id='toggle-deleted-contacts-btn' style='margin:1em 0;'/>"); - $table_with_deleted_contacts.before($toggle_deleted_btn); - $toggle_deleted_btn.on('click', function(e){ - e.preventDefault(); - var $cols = $table_with_deleted_contacts.find('tr.is-deleted'); - if ($cols.first().is(':visible')) { - $cols.hide(); - $(this).prop("value", 'Show deleted contacts'); - } else { - $cols.show(); - $(this).prop("value", 'Hide deleted contacts'); - } - }); - } } $( "#start_date" ).datepicker({ diff --git a/web/js/fixmystreet.js b/web/js/fixmystreet.js index c8f1fe697..78372d68c 100644 --- a/web/js/fixmystreet.js +++ b/web/js/fixmystreet.js @@ -49,10 +49,6 @@ $(function(){ jQuery.validator.addMethod('validCategory', function(value, element) { return this.optional(element) || value != '-- Pick a category --'; }, translation_strings.category ); - jQuery.validator.addMethod('validName', function(value, element) { - var validNamePat = /\ba\s*n+on+((y|o)mo?u?s)?(ly)?\b/i; - return this.optional(element) || value.length > 5 && value.match( /\S/ ) && value.match( /\s/ ) && !value.match( validNamePat ); }, translation_strings.category ); - var form_submitted = 0; var submitted = false; diff --git a/web/js/jquery.fixedthead.js b/web/js/jquery.fixedthead.js new file mode 100644 index 000000000..33e60f721 --- /dev/null +++ b/web/js/jquery.fixedthead.js @@ -0,0 +1,81 @@ +/* + * jQuery.fixedThead.js + * By Zarino at mySociety + */ + +(function ($) { + + // Call this on a <thead> element and it'll be given a class + // of '.js-fixed-thead__clone' when you scroll down. eg: + // $('#my-table thead').fixedThead() + // + // You'll probably want to specify some CSS styles like: + // .js-fixed-thead__clone { position: fixed; background: #fff; } + + $.fn.fixedThead = function() { + + var calculateCloneDimensions = function calculateCloneDimensions($originalThead, $cloneThead){ + $cloneThead.css({ + width: $originalThead.width() + }); + + $('tr', $originalThead).each(function(tr_index, tr){ + $('th', tr).each(function(th_index, th){ + $cloneThead.find('tr:eq(' + tr_index + ') th:eq(' + th_index + ')').css({ + width: $(th).width() + }); + }); + }); + } + + var showOrHideClone = function showOrHideClone($table, $originalThead, $cloneThead){ + var bounds = $table[0].getBoundingClientRect(); + + // First we detect whether *any* of the table is visible, + // then, if it is, we position the fixed thead so that it + // never extends outside of the table bounds even when the + // visible portion of the table is shorter than the thead. + + if(bounds.top <= 0 && bounds.bottom >= 0){ + $cloneThead.css('display', $originalThead.css('display')); + + var rowHeight = $cloneThead.outerHeight(); + if(bounds.bottom < rowHeight){ + $cloneThead.css({ + top: (rowHeight - bounds.bottom) * -1 + }); + } else { + $cloneThead.css({ + top: 0 + }); + } + + } else { + $cloneThead.css('display', 'none'); + } + } + + return this.each(function() { + var $originalThead = $(this); + var $table = $originalThead.parent('table'); + var $cloneThead = $originalThead.clone().addClass('js-fixed-thead__clone'); + + $cloneThead.insertAfter($originalThead); + $cloneThead.css('display', 'none'); + + calculateCloneDimensions($originalThead, $cloneThead); + showOrHideClone($table, $originalThead, $cloneThead); + + $(window).resize(function(){ + calculateCloneDimensions($originalThead, $cloneThead); + showOrHideClone($table, $originalThead, $cloneThead); + }); + + $(window).scroll(function(){ + showOrHideClone($table, $originalThead, $cloneThead); + }); + }); + + }; + +}(jQuery)); diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index baa8d7810..7b7bee7e8 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -9,8 +9,8 @@ function fixmystreet_update_pin(lonlat) { document.getElementById('fixmystreet.longitude').value = lonlat.lon || lonlat.x; $.getJSON('/report/new/ajax', { - latitude: $('#fixmystreet\\.latitude').val(), - longitude: $('#fixmystreet\\.longitude').val() + latitude: $('#fixmystreet\\.latitude').val(), + longitude: $('#fixmystreet\\.longitude').val() }, function(data) { if (data.error) { if (!$('#side-form-error').length) { @@ -29,6 +29,19 @@ function fixmystreet_update_pin(lonlat) { if ( lb.length === 0 ) { lb = $('#form_name').prev(); } lb.before(data.extra_name_info); } + + // If the category filter appears on the map and the user has selected + // something from it, then pre-fill the category field in the report, + // if it's a value already present in the drop-down. + var category = $("#filter_categories").val(); + if (category !== undefined && $("#form_category option[value="+category+"]").length) { + $("#form_category").val(category); + } + + var category_select = $("select#form_category"); + if (category_select.val() != '-- Pick a category --') { + category_select.change(); + } }); if (!$('#side-form-error').is(':visible')) { @@ -69,6 +82,7 @@ function fixmystreet_zoomToBounds(bounds) { function fms_markers_list(pins, transform) { var markers = []; + var size = fms_marker_size_for_zoom(fixmystreet.map.getZoom() + fixmystreet.zoomOffset); for (var i=0; i<pins.length; i++) { var pin = pins[i]; var loc = new OpenLayers.Geometry.Point(pin[1], pin[0]); @@ -81,7 +95,7 @@ function fms_markers_list(pins, transform) { } var marker = new OpenLayers.Feature.Vector(loc, { colour: pin[2], - size: pin[5] || 'normal', + size: pin[5] || size, id: pin[3], title: pin[4] || '' }); @@ -90,6 +104,29 @@ function fms_markers_list(pins, transform) { return markers; } +function fms_marker_size_for_zoom(zoom) { + if (zoom >= 15) { + return 'normal'; + } else if (zoom >= 13) { + return 'small'; + } else { + return 'mini'; + } +} + +function fms_markers_resize() { + var size = fms_marker_size_for_zoom(fixmystreet.map.getZoom() + fixmystreet.zoomOffset); + for (var i = 0; i < fixmystreet.markers.features.length; i++) { + fixmystreet.markers.features[i].attributes.size = size; + } + fixmystreet.markers.redraw(); +} + +function fms_categories_or_status_changed() { + // If the category or status has changed we need to re-fetch map markers + fixmystreet.markers.refresh({force: true}); +} + function fixmystreet_onload() { if ( fixmystreet.area.length ) { for (var i=0; i<fixmystreet.area.length; i++) { @@ -131,7 +168,8 @@ function fixmystreet_onload() { backgroundWidth: 60, backgroundHeight: 30, backgroundXOffset: -7, - backgroundYOffset: -30 + backgroundYOffset: -30, + popupYOffset: -40 }, 'big': { externalGraphic: fixmystreet.pin_prefix + "pin-${colour}-big.png", @@ -144,6 +182,27 @@ function fixmystreet_onload() { backgroundHeight: 40, backgroundXOffset: -10, backgroundYOffset: -35 + }, + 'small': { + externalGraphic: fixmystreet.pin_prefix + "pin-${colour}-small.png", + graphicWidth: 24, + graphicHeight: 32, + graphicXOffset: -12, + graphicYOffset: -32, + backgroundGraphic: fixmystreet.pin_prefix + "pin-shadow-small.png", + backgroundWidth: 30, + backgroundHeight: 15, + backgroundXOffset: -4, + backgroundYOffset: -15, + popupYOffset: -20 + }, + 'mini': { + externalGraphic: fixmystreet.pin_prefix + "pin-${colour}-mini.png", + graphicWidth: 16, + graphicHeight: 20, + graphicXOffset: -8, + graphicYOffset: -20, + popupYOffset: -10 } }); var pin_layer_options = { @@ -155,7 +214,7 @@ function fixmystreet_onload() { if (fixmystreet.page == 'around') { fixmystreet.bbox_strategy = fixmystreet.bbox_strategy || new OpenLayers.Strategy.BBOX({ ratio: 1 }); pin_layer_options.strategies = [ fixmystreet.bbox_strategy ]; - pin_layer_options.protocol = new OpenLayers.Protocol.HTTP({ + pin_layer_options.protocol = new OpenLayers.Protocol.FixMyStreet({ url: '/ajax', params: fixmystreet.all_pins ? { all_pins: 1 } : { }, format: new OpenLayers.Format.FixMyStreet() @@ -186,17 +245,29 @@ function fixmystreet_onload() { fixmystreet.markers.events.register( 'featureselected', fixmystreet.markers, function(evt) { var feature = evt.feature; selectedFeature = feature; + var popupYOffset = feature.layer.styleMap.createSymbolizer(feature).popupYOffset || -40; var popup = new OpenLayers.Popup.FramedCloud("popup", feature.geometry.getBounds().getCenterLonLat(), null, feature.attributes.title + "<br><a href=/report/" + feature.attributes.id + ">" + translation_strings.more_details + "</a>", - { size: new OpenLayers.Size(0,0), offset: new OpenLayers.Pixel(0,-40) }, + { size: new OpenLayers.Size(0, 0), offset: new OpenLayers.Pixel(0, popupYOffset) }, true, onPopupClose); feature.popup = popup; fixmystreet.map.addPopup(popup); }); fixmystreet.map.addControl( fixmystreet.select_feature ); fixmystreet.select_feature.activate(); + fixmystreet.map.events.register( 'zoomend', null, fms_markers_resize ); + + // If the category filter dropdown exists on the page set up the + // event handlers to populate it and react to it changing + if ($("select#filter_categories").length) { + $("body").on("change", "#filter_categories", fms_categories_or_status_changed); + } + // Do the same for the status dropdown + if ($("select#statuses").length) { + $("body").on("change", "#statuses", fms_categories_or_status_changed); + } } else if (fixmystreet.page == 'new') { fixmystreet_activate_drag(); } @@ -288,6 +359,9 @@ $(function(){ if (!fixmystreet.layer_options) { fixmystreet.layer_options = [ {} ]; } + if (!fixmystreet.layer_name) { + fixmystreet.layer_name = ""; + } for (var i=0; i<fixmystreet.layer_options.length; i++) { fixmystreet.layer_options[i] = OpenLayers.Util.extend({ // This option is used by XYZ-based layers @@ -300,7 +374,7 @@ $(function(){ if (fixmystreet.layer_options[i].matrixIds) { layer = new fixmystreet.map_type(fixmystreet.layer_options[i]); } else { - layer = new fixmystreet.map_type("", fixmystreet.layer_options[i]); + layer = new fixmystreet.map_type(fixmystreet.layer_name, fixmystreet.layer_options[i]); } fixmystreet.map.addLayer(layer); } @@ -351,6 +425,16 @@ $(function(){ fixmystreet.page = 'around'; }); + // Hide the pin filter submit button. Not needed because we'll use JS + // to refresh the map when the filter inputs are changed. + $(".report-list-filters [type=submit]").hide(); + + if (fixmystreet.page == "my" || fixmystreet.page == "reports") { + $(".report-list-filters select").change(function() { + $(this).closest("form").submit(); + }); + } + // Vector layers must be added onload as IE sucks if ($.browser.msie) { $(window).load(fixmystreet_onload); @@ -444,6 +528,30 @@ OpenLayers.Control.PermalinkFMSz = OpenLayers.Class(OpenLayers.Control.Permalink } }); +/* Pan data request handler */ +// This class is used to get a JSON object from /ajax that contains +// pins for the map and HTML for the sidebar. It does a fetch whenever the map +// is dragged (modulo a buffer extending outside the viewport). +// This subclass is required so we can pass the 'filter_category' and 'status' query +// params to /ajax if the user has filtered the map. +OpenLayers.Protocol.FixMyStreet = OpenLayers.Class(OpenLayers.Protocol.HTTP, { + read: function(options) { + // Pass the values of the category and status fields as query params + var filter_category = $("#filter_categories").val(); + if (filter_category !== undefined) { + options.params = options.params || {}; + options.params.filter_category = filter_category; + } + var status = $("#statuses").val(); + if (status !== undefined) { + options.params = options.params || {}; + options.params.status = status; + } + return OpenLayers.Protocol.HTTP.prototype.read.apply(this, [options]); + }, + CLASS_NAME: "OpenLayers.Protocol.FixMyStreet" +}); + /* Pan data handler */ OpenLayers.Format.FixMyStreet = OpenLayers.Class(OpenLayers.Format.JSON, { read: function(json, filter) { @@ -459,8 +567,7 @@ OpenLayers.Format.FixMyStreet = OpenLayers.Class(OpenLayers.Format.JSON, { if (typeof(obj.current_near) != 'undefined' && (current_near = document.getElementById('current_near'))) { current_near.innerHTML = obj.current_near; } - var markers = fms_markers_list( obj.pins, false ); - return markers; + return fms_markers_list( obj.pins, false ); }, CLASS_NAME: "OpenLayers.Format.FixMyStreet" }); diff --git a/web/js/map-OpenStreetMap.js b/web/js/map-OpenStreetMap.js index 7ef222da7..5dcf3cab3 100644 --- a/web/js/map-OpenStreetMap.js +++ b/web/js/map-OpenStreetMap.js @@ -8,7 +8,6 @@ function set_map_config(perm) { //new OpenLayers.Control.LayerSwitcher(), new OpenLayers.Control.Navigation(), new OpenLayers.Control.PermalinkFMS(permalink_id), - new OpenLayers.Control.PermalinkFMSz('osm_link', 'https://www.openstreetmap.org/'), new OpenLayers.Control.PanZoomFMS({id: 'fms_pan_zoom' }) ]; } diff --git a/web/js/map-bing-ol.js b/web/js/map-bing-ol.js index 059a5e67e..9b0a73fb8 100644 --- a/web/js/map-bing-ol.js +++ b/web/js/map-bing-ol.js @@ -1,6 +1,4 @@ -var tile_base = [ [ '', 'a-', 'b-', 'c-' ], '//{S}tilma.mysociety.org/sv' ]; - -function set_map_config(perm) { +function _set_map_config() { var permalink_id; if ($('#map_permalink').length) { permalink_id = 'map_permalink'; @@ -23,52 +21,22 @@ function set_map_config(perm) { if ( fixmystreet.page == 'report' ) { fixmystreet.controls.push( new OpenLayers.Control.PermalinkFMS('key-tool-problems-nearby', '/around') ); } +} - if (fixmystreet.map_type) { - tile_base = fixmystreet.map_type; - } - fixmystreet.map_type = OpenLayers.Layer.BingUK; +function set_map_config(perm) { + _set_map_config(); + fixmystreet.map_type = OpenLayers.Layer.Bing; } -OpenLayers.Layer.BingUK = OpenLayers.Class(OpenLayers.Layer.XYZ, { +OpenLayers.Layer.Bing = 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(); - this.map.events.register("moveend", this, this.updateAttribution); }, - updateAttribution: function() { - var z = this.map.getZoom() + this.zoomOffset; - var copyrights; - var logo = ''; - 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="https://www.bing.com/maps/"><img border=0 src="//dev.virtualearth.net/Branding/logo_powered_by.png"></a>'; - copyrights = '© 2011 <a href="https://www.bing.com/maps/">Microsoft</a>. © AND, Navteq, Ordnance Survey'; - } + _updateAttribution: function(copyrights, logo) { this.attribution = OpenLayers.String.format(this.attributionTemplate, { logo: logo, copyrights: copyrights @@ -81,6 +49,12 @@ OpenLayers.Layer.BingUK = OpenLayers.Class(OpenLayers.Layer.XYZ, { } }, + updateAttribution: function() { + var copyrights = '© 2011 <a href="https://www.bing.com/maps/">Microsoft</a>. © AND, Navteq'; + var logo = '<a href="https://www.bing.com/maps/"><img border=0 src="//dev.virtualearth.net/Branding/logo_powered_by.png"></a>'; + this._updateAttribution(copyrights, logo); + }, + initialize: function(name, options) { var url = []; options = OpenLayers.Util.extend({ @@ -89,7 +63,6 @@ OpenLayers.Layer.BingUK = OpenLayers.Class(OpenLayers.Layer.XYZ, { numZoomLevels: 19, sphericalMercator: true, buffer: 0 - //attribution: "© Microsoft / OS 2010" }, options); var newArguments = [name, url, options]; OpenLayers.Layer.XYZ.prototype.initialize.apply(this, newArguments); @@ -121,23 +94,7 @@ OpenLayers.Layer.BingUK = OpenLayers.Class(OpenLayers.Layer.XYZ, { OpenLayers.Util.indexOf(this.serverResolutions, res) : this.map.getZoom() + this.zoomOffset; - var url; - 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 && 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, - "//ecn.t2.tiles.virtualearth.net/tiles/r${id}.png?g=701" + type, - "//ecn.t3.tiles.virtualearth.net/tiles/r${id}.png?g=701" + type - ]; - } + var url = this.get_urls(bounds, z); var s = '' + x + y + z; url = this.selectUrl(s, url); @@ -146,5 +103,14 @@ OpenLayers.Layer.BingUK = OpenLayers.Class(OpenLayers.Layer.XYZ, { return path; }, - CLASS_NAME: "OpenLayers.Layer.BingUK" + get_urls: function(bounds, z) { + return [ + "//ecn.t0.tiles.virtualearth.net/tiles/r${id}.png?g=3467", + "//ecn.t1.tiles.virtualearth.net/tiles/r${id}.png?g=3467", + "//ecn.t2.tiles.virtualearth.net/tiles/r${id}.png?g=3467", + "//ecn.t3.tiles.virtualearth.net/tiles/r${id}.png?g=3467" + ]; + }, + + CLASS_NAME: "OpenLayers.Layer.Bing" }); diff --git a/web/js/map-fms.js b/web/js/map-fms.js new file mode 100644 index 000000000..6ef4265d0 --- /dev/null +++ b/web/js/map-fms.js @@ -0,0 +1,76 @@ +var fms_tile_base = [ [ '', 'a-', 'b-', 'c-' ], '//{S}tilma.mysociety.org/sv' ]; + +function set_map_config(perm) { + _set_map_config(); + + if (fixmystreet.map_type) { + fms_tile_base = fixmystreet.map_type; + } + fixmystreet.map_type = OpenLayers.Layer.BingUK; +} + +OpenLayers.Layer.BingUK = OpenLayers.Class(OpenLayers.Layer.Bing, { + 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.Bing.prototype.setMap.apply(this, arguments); + this.map.events.register("moveend", this, this.updateAttribution); + }, + + updateAttribution: function() { + var z = this.map.getZoom() + this.zoomOffset; + var copyrights; + var logo = ''; + 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 2014'; + } else { + logo = '<a href="https://www.bing.com/maps/"><img border=0 src="//dev.virtualearth.net/Branding/logo_powered_by.png"></a>'; + copyrights = '© 2011 <a href="https://www.bing.com/maps/">Microsoft</a>. © AND, Navteq, Ordnance Survey'; + } + this._updateAttribution(copyrights, logo); + }, + + get_urls: function(bounds, z) { + var urls; + var in_uk = this.in_uk(bounds.getCenterLonLat()); + if (z >= 16 && in_uk) { + urls = []; + for (var i=0; i< fms_tile_base[0].length; i++) { + urls.push( fms_tile_base[1].replace('{S}', fms_tile_base[0][i]) + "/${z}/${x}/${y}.png" ); + } + } else { + var type = ''; + if (z > 10 && in_uk) { + type = '&productSet=mmOS&key=' + fixmystreet.key; + } + urls = [ + "//ecn.t0.tiles.virtualearth.net/tiles/r${id}.png?g=3467" + type, + "//ecn.t1.tiles.virtualearth.net/tiles/r${id}.png?g=3467" + type, + "//ecn.t2.tiles.virtualearth.net/tiles/r${id}.png?g=3467" + type, + "//ecn.t3.tiles.virtualearth.net/tiles/r${id}.png?g=3467" + type + ]; + } + return urls; + }, + + CLASS_NAME: "OpenLayers.Layer.BingUK" +}); diff --git a/web/js/map-google-ol.js b/web/js/map-google-ol.js index 5d128a7bd..a0e58cdc2 100644 --- a/web/js/map-google-ol.js +++ b/web/js/map-google-ol.js @@ -1,9 +1,9 @@ $(function(){ $('#map_layer_toggle').toggle(function(){ - $(this).text(translation_strings.map_map); + $(this).text(translation_strings.map_satellite); fixmystreet.map.setBaseLayer(fixmystreet.map.layers[1]); }, function(){ - $(this).text(translation_strings.map_satellite); + $(this).text(translation_strings.map_map); fixmystreet.map.setBaseLayer(fixmystreet.map.layers[0]); }); }); @@ -26,8 +26,8 @@ function set_map_config(perm) { zoomDuration: 10 }; fixmystreet.layer_options = [ - {}, - { type: google.maps.MapTypeId.HYBRID } + { type: google.maps.MapTypeId.HYBRID }, + {} ]; } diff --git a/web/js/map-streetview.js b/web/js/map-streetview.js index b81438a88..58d856781 100644 --- a/web/js/map-streetview.js +++ b/web/js/map-streetview.js @@ -1,7 +1,6 @@ function set_map_config(perm) { fixmystreet.controls = [ new OpenLayers.Control.ArgParser(), - //new OpenLayers.Control.LayerSwitcher(), new OpenLayers.Control.Navigation(), new OpenLayers.Control.Permalink(), new OpenLayers.Control.PanZoomFMS() @@ -38,8 +37,7 @@ OpenLayers.Layer.StreetView = OpenLayers.Class(OpenLayers.Layer.XYZ, { /* Below line added to OSM's file in order to allow minimum zoom level */ maxResolution: 156543.03390625/Math.pow(2, options.zoomOffset || 0), numZoomLevels: 19, - sphericalMercator: true, - attribution: "Contains Ordnance Survey data © Crown copyright and database right 2012" + sphericalMercator: true }, options); var newArguments = [name, url, options]; OpenLayers.Layer.XYZ.prototype.initialize.apply(this, newArguments); diff --git a/web/js/map-toner-lite.js b/web/js/map-toner-lite.js new file mode 100644 index 000000000..5291d0254 --- /dev/null +++ b/web/js/map-toner-lite.js @@ -0,0 +1,19 @@ +function set_map_config(perm) { + var permalink_id; + if ($('#map_permalink').length) { + permalink_id = 'map_permalink'; + } + fixmystreet.controls = [ + new OpenLayers.Control.ArgParser(), + new OpenLayers.Control.Navigation(), + new OpenLayers.Control.PermalinkFMS(permalink_id), + new OpenLayers.Control.PanZoomFMS({id: 'fms_pan_zoom' }) + ]; + fixmystreet.layer_options = [ { + maxResolution: 156543.03390625/Math.pow(2, fixmystreet.zoomOffset) + } ]; + fixmystreet.layer_name = 'toner-lite'; + + // The Stamen JS returns HTTP urls, fix that + stamen.tile.getProvider('toner-lite').url = 'https://stamen-tiles-{S}a.ssl.fastly.net/toner-lite/{Z}/{X}/{Y}.png'; +} diff --git a/web/js/map-wmts-zurich.js b/web/js/map-wmts-zurich.js index cfff686e6..54b932168 100644 --- a/web/js/map-wmts-zurich.js +++ b/web/js/map-wmts-zurich.js @@ -63,7 +63,6 @@ $(function(){ fixmystreet.nav_control = new OpenLayers.Control.Navigation(nav_opts); fixmystreet.controls = [ - new OpenLayers.Control.Attribution(), new OpenLayers.Control.ArgParser(), fixmystreet.nav_control ]; |