aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md2
-rw-r--r--perllib/FixMyStreet/Map/Bing.pm10
-rw-r--r--perllib/FixMyStreet/Map/OSM.pm4
-rw-r--r--templates/web/base/maps/_sub_links.html6
-rw-r--r--templates/web/base/maps/bing.html9
-rw-r--r--templates/web/base/maps/fms.html2
-rw-r--r--templates/web/base/maps/google-ol.html2
-rw-r--r--templates/web/base/maps/openlayers.html6
-rw-r--r--templates/web/base/maps/osm.html8
-rw-r--r--templates/web/zurich/maps/zurich.html5
-rw-r--r--web/js/map-OpenStreetMap.js7
-rw-r--r--web/js/map-bing-ol.js4
12 files changed, 32 insertions, 33 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2af6f052c..9f7dc615b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,7 +9,7 @@
- Add lazy image loading on list items.
- Improve Bing geocoder results.
- Add option of checking passwords against Have I Been Pwned.
- - Add aerial maps option to Bing maps.
+ - Add aerial maps option to Bing and OSM maps.
- Changes:
- Mark user as active when sent an email alert.
- Bugfixes:
diff --git a/perllib/FixMyStreet/Map/Bing.pm b/perllib/FixMyStreet/Map/Bing.pm
index 723dcd6dc..17bdc3a53 100644
--- a/perllib/FixMyStreet/Map/Bing.pm
+++ b/perllib/FixMyStreet/Map/Bing.pm
@@ -8,8 +8,6 @@ use strict;
sub map_type { '' }
-sub map_template { 'bing' }
-
sub map_javascript { [
'/vendor/OpenLayers/OpenLayers.fixmystreet.js',
'/js/map-OpenLayers.js',
@@ -31,14 +29,6 @@ sub get_quadkey {
return $key;
}
-sub display_map {
- my ($self, $c, %params) = @_;
-
- $params{aerial} = $c->get_param("aerial") ? 1 : 0;
-
- $self->SUPER::display_map($c, %params);
-}
-
my $road_base = '//%s.ssl.ak.dynamic.tiles.virtualearth.net/comp/ch/%s?mkt=en-US&it=G,L&src=t&shading=hill&og=969&n=z';
my $aerial_base = '//%s.ssl.ak.dynamic.tiles.virtualearth.net/comp/ch/%s?mkt=en-US&it=A,G,L&src=t&og=969&n=z';
diff --git a/perllib/FixMyStreet/Map/OSM.pm b/perllib/FixMyStreet/Map/OSM.pm
index 417fdca0b..47c1c8535 100644
--- a/perllib/FixMyStreet/Map/OSM.pm
+++ b/perllib/FixMyStreet/Map/OSM.pm
@@ -21,11 +21,13 @@ sub map_template { 'osm' }
sub map_javascript { [
'/vendor/OpenLayers/OpenLayers.wfs.js',
'/js/map-OpenLayers.js',
+ FixMyStreet->config('BING_MAPS_API_KEY') ? ('/js/map-bing-ol.js') : (),
'/js/map-OpenStreetMap.js',
] }
sub map_tiles {
my ( $self, %params ) = @_;
+ return FixMyStreet::Map::Bing->map_tiles(%params) if $params{aerial};
my ( $x, $y, $z ) = ( $params{x_tile}, $params{y_tile}, $params{zoom_act} );
my $tile_url = $self->base_tile_url();
return [
@@ -59,6 +61,8 @@ sub display_map {
if defined $c->get_param('lon');
$params{zoomToBounds} = $params{any_zoom} && !defined $c->get_param('zoom');
+ $params{aerial} = $c->get_param("aerial") && FixMyStreet->config('BING_MAPS_API_KEY') ? 1 : 0;
+
my %data;
$data{cobrand} = $c->cobrand;
$data{distance} = $c->stash->{distance};
diff --git a/templates/web/base/maps/_sub_links.html b/templates/web/base/maps/_sub_links.html
deleted file mode 100644
index d58ecf97c..000000000
--- a/templates/web/base/maps/_sub_links.html
+++ /dev/null
@@ -1,6 +0,0 @@
-[% INCLUDE maps/openlayers.html %]
-[% UNLESS around_page %]
-<p class="sub-map-links" id="sub_map_links">
- [% map_sub_links | safe %]
-</p>
-[% END %]
diff --git a/templates/web/base/maps/bing.html b/templates/web/base/maps/bing.html
deleted file mode 100644
index 7d2c379c4..000000000
--- a/templates/web/base/maps/bing.html
+++ /dev/null
@@ -1,9 +0,0 @@
-[% map_sub_links = BLOCK %]
- [% IF c.req.params.aerial %]
- <a id="map_layer_toggle" href="[% c.uri_with( { aerial => 0 } ) %]">[% loc('Roads') %]</a>
- [% ELSE %]
- <a id="map_layer_toggle" href="[% c.uri_with( { aerial => 1 } ) %]">[% loc('Aerial') %]</a>
- [% END %]
-[% END %]
-
-[% map_html = INCLUDE maps/_sub_links.html %]
diff --git a/templates/web/base/maps/fms.html b/templates/web/base/maps/fms.html
index 739c00b4e..2df3bd11b 100644
--- a/templates/web/base/maps/fms.html
+++ b/templates/web/base/maps/fms.html
@@ -6,4 +6,4 @@
[% END %]
[% END %]
-[% map_html = INCLUDE maps/_sub_links.html include_key = 1 %]
+[% map_html = INCLUDE maps/openlayers.html include_key = 1 %]
diff --git a/templates/web/base/maps/google-ol.html b/templates/web/base/maps/google-ol.html
index eb68ae804..9103ba42b 100644
--- a/templates/web/base/maps/google-ol.html
+++ b/templates/web/base/maps/google-ol.html
@@ -2,4 +2,4 @@
<a class="hidden-nojs" id="map_layer_toggle" href="">[% loc('Satellite') %]</a>
[% END %]
-[% map_html = INCLUDE maps/_sub_links.html %]
+[% map_html = INCLUDE maps/openlayers.html %]
diff --git a/templates/web/base/maps/openlayers.html b/templates/web/base/maps/openlayers.html
index f4c78767c..60d7acfde 100644
--- a/templates/web/base/maps/openlayers.html
+++ b/templates/web/base/maps/openlayers.html
@@ -46,3 +46,9 @@
<div class="olControlAttribution" style="position: absolute;">[% map.copyright | safe %]</div>
[% END %]
<img id="loading-indicator" class="hidden" aria-hidden="true" src="/i/loading.svg" alt="Loading...">
+
+[% IF NOT around_page AND map_sub_links %]
+<p class="sub-map-links" id="sub_map_links">
+ [% map_sub_links | safe %]
+</p>
+[% END %]
diff --git a/templates/web/base/maps/osm.html b/templates/web/base/maps/osm.html
index 70d05929f..560055f3b 100644
--- a/templates/web/base/maps/osm.html
+++ b/templates/web/base/maps/osm.html
@@ -1,3 +1,11 @@
+[% map_sub_links = BLOCK %][% IF c.config.BING_MAPS_API_KEY %]
+ [% IF c.req.params.aerial %]
+ <a id="map_layer_toggle" href="[% c.uri_with( { aerial => 0 } ) %]">[% loc('Roads') %]</a>
+ [% ELSE %]
+ <a id="map_layer_toggle" href="[% c.uri_with( { aerial => 1 } ) %]">[% loc('Aerial') %]</a>
+ [% END %]
+[% END %][% END %]
+
[%
map.copyright = ''; # This is handled with OpenLayers.Control.Attribution
map_html = INCLUDE maps/openlayers.html
diff --git a/templates/web/zurich/maps/zurich.html b/templates/web/zurich/maps/zurich.html
index f3a9bdc7f..8310b0758 100644
--- a/templates/web/zurich/maps/zurich.html
+++ b/templates/web/zurich/maps/zurich.html
@@ -5,9 +5,4 @@
[% map_html = BLOCK %]
[% INCLUDE maps/openlayers.html %]
[% INCLUDE maps/wmts_config.html %]
-[% UNLESS around_page %]
-<p class="sub-map-links" id="sub_map_links">
- [% map_sub_links | safe %]
-</p>
-[% END %]
[% END %]
diff --git a/web/js/map-OpenStreetMap.js b/web/js/map-OpenStreetMap.js
index 9ed3a2ee3..bd3497343 100644
--- a/web/js/map-OpenStreetMap.js
+++ b/web/js/map-OpenStreetMap.js
@@ -7,6 +7,13 @@ fixmystreet.maps.config = function() {
new OpenLayers.Control.PermalinkFMS('map'),
new OpenLayers.Control.PanZoomFMS({id: 'fms_pan_zoom' })
];
+
+ if (OpenLayers.Layer.BingAerial) {
+ fixmystreet.layer_options = [
+ { map_type: fixmystreet.map_type },
+ { map_type: OpenLayers.Layer.BingAerial }
+ ];
+ }
};
// http://www.openstreetmap.org/openlayers/OpenStreetMap.js (added maxResolution)
diff --git a/web/js/map-bing-ol.js b/web/js/map-bing-ol.js
index b0e5dfc6a..179238633 100644
--- a/web/js/map-bing-ol.js
+++ b/web/js/map-bing-ol.js
@@ -25,6 +25,10 @@ fixmystreet.maps.config = function() {
fixmystreet.map.setBaseLayer(fixmystreet.map.layers[0]);
}
});
+ // If page loaded with Aerial as starting, rather than default road
+ if ($('#map_layer_toggle').text() == translation_strings.map_roads) {
+ fixmystreet.map.setBaseLayer(fixmystreet.map.layers[1]);
+ }
});
})();