aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/Cobrand/Bristol.pm2
-rw-r--r--perllib/FixMyStreet/Cobrand/Default.pm25
-rw-r--r--perllib/FixMyStreet/Cobrand/FixaMinGata.pm11
-rw-r--r--perllib/FixMyStreet/Cobrand/Zurich.pm9
-rw-r--r--web/cobrands/fixmystreet/fixmystreet.js9
-rw-r--r--web/js/map-OpenLayers.js2
6 files changed, 25 insertions, 33 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Bristol.pm b/perllib/FixMyStreet/Cobrand/Bristol.pm
index faf2b5f0a..ecb19b867 100644
--- a/perllib/FixMyStreet/Cobrand/Bristol.pm
+++ b/perllib/FixMyStreet/Cobrand/Bristol.pm
@@ -23,6 +23,8 @@ sub map_type {
'Bristol';
}
+sub default_link_zoom { 6 }
+
sub disambiguate_location {
my $self = shift;
my $string = shift;
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm
index c44842dea..3dd562dc4 100644
--- a/perllib/FixMyStreet/Cobrand/Default.pm
+++ b/perllib/FixMyStreet/Cobrand/Default.pm
@@ -382,22 +382,14 @@ sub cobrand_data_for_generic_problem { '' }
Given a URL ($_[1]), QUERY, EXTRA_DATA, return a URL with any extra params
needed appended to it.
-In the default case, if we're using an OpenLayers map, we need to make
-sure zoom is always present if lat/lon are, to stop OpenLayers defaulting
-to null/0.
+In the default case, we need to make sure zoom is always present if lat/lon
+are, to stop OpenLayers defaulting to null/0.
=cut
sub uri {
my ( $self, $uri ) = @_;
-
- {
- no warnings 'once';
- my $map_class = $FixMyStreet::Map::map_class;
- return $uri unless $map_class && $map_class =~ /FixMyStreet::Map::(OSM|FMS)/;
- }
-
- $uri->query_param( zoom => 3 )
+ $uri->query_param( zoom => $self->default_link_zoom )
if $uri->query_param('lat') && !$uri->query_param('zoom');
return $uri;
@@ -981,7 +973,18 @@ sub tweak_all_reports_map {}
sub can_support_problems { return 0; }
+=head2 default_map_zoom / default_link_zoom
+
+default_map_zoom is used when displaying a map overriding the
+default of max-4 or max-3 depending on population density.
+
+default_link_zoom is used in links that contain a 'lat' and no
+zoom, to stop e.g. OpenLayers defaulting to null/0.
+
+=cut
+
sub default_map_zoom { undef };
+sub default_link_zoom { 3 }
sub users_can_hide { return 0; }
diff --git a/perllib/FixMyStreet/Cobrand/FixaMinGata.pm b/perllib/FixMyStreet/Cobrand/FixaMinGata.pm
index a321d5c7c..5b78b3fa1 100644
--- a/perllib/FixMyStreet/Cobrand/FixaMinGata.pm
+++ b/perllib/FixMyStreet/Cobrand/FixaMinGata.pm
@@ -35,17 +35,6 @@ sub area_types {
[ 'KOM' ];
}
-# If lat/lon are present in the URL, OpenLayers will use that to centre the map.
-# Need to specify a zoom to stop it defaulting to null/0.
-sub uri {
- my ( $self, $uri ) = @_;
-
- $uri->query_param( zoom => 3 )
- if $uri->query_param('lat') && !$uri->query_param('zoom');
-
- return $uri;
-}
-
sub geocode_postcode {
my ( $self, $s ) = @_;
# Most people write Swedish postcodes like this:
diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm
index b8e2db9d4..dca722224 100644
--- a/perllib/FixMyStreet/Cobrand/Zurich.pm
+++ b/perllib/FixMyStreet/Cobrand/Zurich.pm
@@ -83,14 +83,7 @@ sub example_places {
sub languages { [ 'de-ch,Deutsch,de_CH' ] }
sub language_override { 'de-ch' }
-# If lat/lon are in the URI, we must have zoom as well, otherwise OpenLayers defaults to 0.
-sub uri {
- my ( $self, $uri ) = @_;
-
- $uri->query_param( zoom => 6 )
- if $uri->query_param('lat') && !$uri->query_param('zoom');
- return $uri;
-}
+sub default_link_zoom { 6 }
sub prettify_dt {
my $self = shift;
diff --git a/web/cobrands/fixmystreet/fixmystreet.js b/web/cobrands/fixmystreet/fixmystreet.js
index fea863b14..53954f57a 100644
--- a/web/cobrands/fixmystreet/fixmystreet.js
+++ b/web/cobrands/fixmystreet/fixmystreet.js
@@ -1087,15 +1087,19 @@ fixmystreet.display = {
// If this is the first individual report we've loaded, remove the
// "all reports" sub_map_links but store them in a global variable
// so we can reinsert them when the user returns to the all reports
- // view. Also set the Back link to know where to go back to.
+ // view.
if (!fixmystreet.original.sub_map_links) {
fixmystreet.original.sub_map_links = $('#sub_map_links').detach();
- $('.js-back-to-report-list').attr('href', location.href);
}
// With #sub_map_links detached from the DOM, we set up the
// individual report's sub_map_links using map_controls().
fixmystreet.set_up.map_controls();
+ // Set the Back link to know where to go back to.
+ // TODO: If you e.g. filter before selecting a report, this URL is
+ // wrong (but what is shown is correct).
+ $('.js-back-to-report-list').attr('href', fixmystreet.original.href);
+
// Problems nearby should act the same as 'Back to all reports' on around,
// but on /my and /reports should go to that around page.
if (fixmystreet.original.page == 'around') {
@@ -1179,6 +1183,7 @@ fixmystreet.display = {
$(function() {
fixmystreet.original = {
+ 'href': location.href,
'title': document.title,
'page': fixmystreet.page
};
diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js
index e48531152..02a0d7727 100644
--- a/web/js/map-OpenLayers.js
+++ b/web/js/map-OpenLayers.js
@@ -473,7 +473,7 @@ var fixmystreet = fixmystreet || {};
if (fixmystreet.page == 'reports' || fixmystreet.page == 'my') {
pin_layer_options.strategies = [ new OpenLayers.Strategy.FixMyStreetFixed() ];
pin_layer_options.protocol = new OpenLayers.Protocol.FixMyStreet({
- url: '?ajax=1',
+ url: fixmystreet.original.href.split('?')[0] + '?ajax=1',
format: new OpenLayers.Format.FixMyStreet()
});
}