From 5370647bfa52503948148753bad7bca5c463d79c Mon Sep 17 00:00:00 2001 From: pezholio Date: Fri, 17 Mar 2017 16:36:24 +0000 Subject: Show loading indicator when loading pins --- web/js/map-OpenLayers.js | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'web/js/map-OpenLayers.js') diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index 49801911b..2a5af940d 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -801,6 +801,9 @@ OpenLayers.Strategy.FixMyStreetFixed = OpenLayers.Class(OpenLayers.Strategy.Fixe // params to /ajax if the user has filtered the map. OpenLayers.Protocol.FixMyStreet = OpenLayers.Class(OpenLayers.Protocol.HTTP, { read: function(options) { + // Show the loading indicator over the map + $('#loading-indicator').removeClass('hidden'); + $('#loading-indicator').attr('aria-hidden', false); // Pass the values of the category, status, and sort fields as query params $.each({ filter_category: 'filter_categories', status: 'statuses', sort: 'sort' }, function(key, id) { var val = $('#' + id).val(); @@ -817,17 +820,9 @@ OpenLayers.Protocol.FixMyStreet = OpenLayers.Class(OpenLayers.Protocol.HTTP, { /* Pan data handler */ OpenLayers.Format.FixMyStreet = OpenLayers.Class(OpenLayers.Format.JSON, { read: function(json, filter) { - // Check we haven't received the data after the map has been clicked. - if (fixmystreet.page == 'new') { - // If we have, we want to do nothing, which means returning an - // array of the back-projected version of the current pin - var pin = fixmystreet.markers.features[0].clone(); - pin.geometry.transform( - fixmystreet.map.getProjectionObject(), - new OpenLayers.Projection("EPSG:4326") - ); - return [ pin ]; - } + // Remove loading indicator + $('#loading-indicator').addClass('hidden'); + $('#loading-indicator').attr('aria-hidden', true); if (typeof json == 'string') { obj = OpenLayers.Format.JSON.prototype.read.apply(this, [json, filter]); } else { -- cgit v1.2.3 From 21bde113503d86f1791e170d1133710a2ed32077 Mon Sep 17 00:00:00 2001 From: Dave Arter Date: Thu, 16 Mar 2017 10:38:34 -0400 Subject: =?UTF-8?q?Use=20lat/lon=20on=20inspection=20form=20if=20local=20c?= =?UTF-8?q?oordinates=20aren=E2=80=99t=20available?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/js/map-OpenLayers.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'web/js/map-OpenLayers.js') diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index 2a5af940d..40539f385 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -331,6 +331,8 @@ var fixmystreet = fixmystreet || {}; ); $("#problem_northing").text(bng.y.toFixed(1)); $("#problem_easting").text(bng.x.toFixed(1)); + $("#problem_latitude").text(lonlat.y.toFixed(6)); + $("#problem_longitude").text(lonlat.x.toFixed(6)); $("form#report_inspect_form input[name=latitude]").val(lonlat.y); $("form#report_inspect_form input[name=longitude]").val(lonlat.x); }, -- cgit v1.2.3 From ef6ffbdbfa562dca1825a0abc06afb0e52509737 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Thu, 13 Apr 2017 16:48:57 +0100 Subject: On /reports maps, only include reports in view. Update the reports with a bounding box, similar to on around pages. This is made slightly trickier because we don't want to do anything on page load (we already have the pins), we need to reload when the zoom changes, and we don't want the strategy to get confused by its first redraw, e.g. on pin hover, We also need to turn off the zoom- to-bounds if we've got a bounding box in the URL. --- web/js/map-OpenLayers.js | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 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 40539f385..b53246279 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -215,14 +215,21 @@ var fixmystreet = fixmystreet || {}; } }; + /* Make sure pins aren't going to reload just because we're zooming out, + * we already have the pins when the page loaded */ function zoomToBounds(bounds) { if (!bounds) { return; } + fixmystreet.markers.strategies[0].deactivate(); var center = bounds.getCenterLonLat(); var z = fixmystreet.map.getZoomForExtent(bounds); if ( z < 13 && $('html').hasClass('mobile') ) { z = 13; } fixmystreet.map.setCenter(center, z); + // Reactivate the strategy and make it think it's done an update + fixmystreet.markers.strategies[0].activate(); + fixmystreet.markers.strategies[0].calculateBounds(); + fixmystreet.markers.strategies[0].resolution = fixmystreet.map.getResolution(); } function sidebar_highlight(problem_id) { @@ -391,7 +398,10 @@ var fixmystreet = fixmystreet || {}; f.geometry = new_geometry; this.removeAllFeatures(); this.addFeatures([f]); - zoomToBounds(extent); + var qs = parse_query_string(); + if (!qs.bbox) { + zoomToBounds(extent); + } } else { fixmystreet.map.removeLayer(this); } @@ -478,8 +488,13 @@ var fixmystreet = fixmystreet || {}; format: new OpenLayers.Format.FixMyStreet() }); } - if (fixmystreet.page == 'reports' || fixmystreet.page == 'my') { + if (fixmystreet.page == 'reports') { + pin_layer_options.strategies = [ new OpenLayers.Strategy.FixMyStreetRefreshOnZoom() ]; + } + if (fixmystreet.page == 'my') { pin_layer_options.strategies = [ new OpenLayers.Strategy.FixMyStreetFixed() ]; + } + if (fixmystreet.page == 'reports' || fixmystreet.page == 'my') { pin_layer_options.protocol = new OpenLayers.Protocol.FixMyStreet({ url: fixmystreet.original.href.split('?')[0] + '?ajax=1', format: new OpenLayers.Format.FixMyStreet() @@ -781,6 +796,25 @@ OpenLayers.Strategy.FixMyStreet = OpenLayers.Class(OpenLayers.Strategy.BBOX, { } }); +/* This strategy will call for updates whenever the zoom changes, + * unlike the parent which only will if new area is included. It + * also does not update on load, as we already have the data. */ +OpenLayers.Strategy.FixMyStreetRefreshOnZoom = OpenLayers.Class(OpenLayers.Strategy.FixMyStreet, { + resFactor: 1.5, + activate: function() { + var activated = OpenLayers.Strategy.prototype.activate.call(this); + if (activated) { + this.layer.events.on({ + "moveend": this.update, + "refresh": this.update, + "visibilitychanged": this.update, + scope: this + }); + } + return activated; + } +}); + /* Copy of Strategy.Fixed, but with no initial load */ OpenLayers.Strategy.FixMyStreetFixed = OpenLayers.Class(OpenLayers.Strategy.Fixed, { activate: function() { -- cgit v1.2.3