From 032db2fbb6bd2bf0cf0cf2daa379610ab319a6a8 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Mon, 6 Oct 2014 15:47:21 +0000 Subject: Support Stamen toner-lite and Bing Maps tiles. --- web/js/map-OpenLayers.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'web/js/map-OpenLayers.js') diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index baa8d7810..3088cc764 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -288,6 +288,9 @@ $(function(){ if (!fixmystreet.layer_options) { fixmystreet.layer_options = [ {} ]; } + if (!fixmystreet.layer_name) { + fixmystreet.layer_name = ""; + } for (var i=0; i Date: Mon, 23 Feb 2015 11:17:39 +0000 Subject: Resize map pins based on zoom level When zoomed out, a smaller icon is used to stop the map getting too overcrowded. --- web/js/map-OpenLayers.js | 49 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) (limited to 'web/js/map-OpenLayers.js') diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index 3088cc764..c227a366e 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -69,6 +69,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= 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 fixmystreet_onload() { if ( fixmystreet.area.length ) { for (var i=0; i" + translation_strings.more_details + "", - { 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 ); } else if (fixmystreet.page == 'new') { fixmystreet_activate_drag(); } -- cgit v1.2.3 From 09f94956ecd20a7aa861d0f7254189fd9373b813 Mon Sep 17 00:00:00 2001 From: Dave Arter Date: Fri, 27 Feb 2015 12:51:29 +0000 Subject: Add category filtering support to /ajax via 'category' GET param --- web/js/map-OpenLayers.js | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'web/js/map-OpenLayers.js') diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index c227a366e..f459459ec 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -196,7 +196,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() @@ -490,6 +490,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 '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 category = $("#categories").val(); + if (category !== undefined) { + options.params = options.params || {}; + options.params.category = 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) { -- cgit v1.2.3 From 2ab9918c650631e054c44dd23b73451251280b6c Mon Sep 17 00:00:00 2001 From: Steven Day Date: Tue, 23 Jun 2015 15:57:51 +0100 Subject: Change map pins with category field When the category dropdown is changed the map pins are re-requested from the server with the correct category in the URL. --- web/js/map-OpenLayers.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'web/js/map-OpenLayers.js') diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index f459459ec..2995c3bd0 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -109,6 +109,12 @@ function fms_markers_resize() { fixmystreet.markers.redraw(); } +function fms_categories_changed() { + // If the category has changed we need to re-fetch markers that match + // the new value + fixmystreet.markers.refresh({force: true}); +} + function fixmystreet_onload() { if ( fixmystreet.area.length ) { for (var i=0; i Date: Tue, 3 Mar 2015 16:09:39 +0000 Subject: Pre-fill category on report form if map pins were filtered --- web/js/map-OpenLayers.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'web/js/map-OpenLayers.js') diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index 2995c3bd0..bb78191a8 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -29,6 +29,13 @@ 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 = $("#categories").val(); + if (category !== undefined && $("#form_category option[value="+category+"]").length) { + $("#form_category").val(category); + } }); if (!$('#side-form-error').is(':visible')) { @@ -402,6 +409,7 @@ $(function(){ fixmystreet.drag.deactivate(); $('#side-form').hide(); $('#side').show(); + $("select#categories").attr("name", "category"); $('#sub_map_links').show(); //only on mobile $('#mob_sub_map_links').remove(); @@ -614,6 +622,12 @@ OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, { document.getElementById('side-form').style.display = 'block'; } $('#side').hide(); + // Although it's now hidden, the category filter for the map is still + // posted to the server when the report is sent. The name clashes with + // the category select element in the report form, which can cause + // issues with the wrong/no category being used for the report. + // Work around this by renaming the field when it's not shown. + $("select#categories").attr("name", "category_filter"); if (typeof heightFix !== 'undefined') { heightFix('#report-a-problem-sidebar', '.content', 26); } -- cgit v1.2.3 From 53314bb25e2ff7ddde33fabcd2f4505d09fcc220 Mon Sep 17 00:00:00 2001 From: Steven Day Date: Tue, 23 Jun 2015 16:00:52 +0100 Subject: Refresh map pins when status dropdown changes, if present --- web/js/map-OpenLayers.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'web/js/map-OpenLayers.js') diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index bb78191a8..5b8deec06 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -116,9 +116,8 @@ function fms_markers_resize() { fixmystreet.markers.redraw(); } -function fms_categories_changed() { - // If the category has changed we need to re-fetch markers that match - // the new value +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}); } @@ -257,7 +256,11 @@ function fixmystreet_onload() { // If the category filter dropdown exists on the page set up the // event handlers to populate it and react to it changing if ($("select#categories").length) { - $("body").on("change", "#categories", fms_categories_changed); + $("body").on("change", "#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(); -- cgit v1.2.3 From be12a9abd8447ecba3d6468a3ec0059dcf480e93 Mon Sep 17 00:00:00 2001 From: Dave Arter Date: Tue, 24 Mar 2015 09:37:45 +0000 Subject: Refresh map as soon as filters are changed on /my and /reports --- web/js/map-OpenLayers.js | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'web/js/map-OpenLayers.js') diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index 5b8deec06..c60ded3f9 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -424,6 +424,12 @@ $(function(){ // 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); -- cgit v1.2.3 From 69ed1cda6a315a46e3309dcf3035ad7229931829 Mon Sep 17 00:00:00 2001 From: Steven Day Date: Mon, 29 Jun 2015 12:03:17 +0100 Subject: Rename map filtering GET param, remove unnecessary query --- web/js/map-OpenLayers.js | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'web/js/map-OpenLayers.js') diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index c60ded3f9..a0ab4f34c 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -32,7 +32,7 @@ function fixmystreet_update_pin(lonlat) { // 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 = $("#categories").val(); + var category = $("#filter_categories").val(); if (category !== undefined && $("#form_category option[value="+category+"]").length) { $("#form_category").val(category); } @@ -255,8 +255,8 @@ function fixmystreet_onload() { // If the category filter dropdown exists on the page set up the // event handlers to populate it and react to it changing - if ($("select#categories").length) { - $("body").on("change", "#categories", fms_categories_or_status_changed); + 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) { @@ -412,7 +412,6 @@ $(function(){ fixmystreet.drag.deactivate(); $('#side-form').hide(); $('#side').show(); - $("select#categories").attr("name", "category"); $('#sub_map_links').show(); //only on mobile $('#mob_sub_map_links').remove(); @@ -527,15 +526,15 @@ OpenLayers.Control.PermalinkFMSz = OpenLayers.Class(OpenLayers.Control.Permalink // 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 'category' and 'status' query +// 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 category = $("#categories").val(); - if (category !== undefined) { + var filter_category = $("#filter_categories").val(); + if (filter_category !== undefined) { options.params = options.params || {}; - options.params.category = category; + options.params.filter_category = filter_category; } var status = $("#statuses").val(); if (status !== undefined) { @@ -631,12 +630,6 @@ OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, { document.getElementById('side-form').style.display = 'block'; } $('#side').hide(); - // Although it's now hidden, the category filter for the map is still - // posted to the server when the report is sent. The name clashes with - // the category select element in the report form, which can cause - // issues with the wrong/no category being used for the report. - // Work around this by renaming the field when it's not shown. - $("select#categories").attr("name", "category_filter"); if (typeof heightFix !== 'undefined') { heightFix('#report-a-problem-sidebar', '.content', 26); } -- cgit v1.2.3 From a6390b55a0f05ef348b831ad76ce07834ac26e7e Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Fri, 19 Jun 2015 19:07:19 +0100 Subject: If only one category, be sure to fetch extras for it. --- web/js/map-OpenLayers.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'web/js/map-OpenLayers.js') diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index a0ab4f34c..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,7 @@ 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. @@ -36,6 +37,11 @@ function fixmystreet_update_pin(lonlat) { 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')) { -- cgit v1.2.3