aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2015-09-17 18:21:54 +0100
committerMatthew Somerville <matthew@mysociety.org>2015-09-17 18:21:54 +0100
commitae05cc5d953f0de784ade62579f49840178d37c1 (patch)
treecd142754f199720268a8e368b90371ad0c170197
parentb8db6263a378a3486b670b588d2870df9d4170f4 (diff)
Allow Google map/hybrid initial view to be chosen.
The GoogleOL layer will default to map, unless the fixmystreet_google_default variable is set to 'satellite'.
-rw-r--r--templates/web/base/maps/google-ol.html2
-rw-r--r--web/js/map-google-ol.js24
2 files changed, 17 insertions, 9 deletions
diff --git a/templates/web/base/maps/google-ol.html b/templates/web/base/maps/google-ol.html
index 58db01856..021570df1 100644
--- a/templates/web/base/maps/google-ol.html
+++ b/templates/web/base/maps/google-ol.html
@@ -10,7 +10,7 @@
[% END %]
[% map_sub_links = BLOCK %]
-<a class="hidden-nojs" id="map_layer_toggle" href="">[% loc('Map') %]</a>
+<a class="hidden-nojs" id="map_layer_toggle" href="">[% loc('Satellite') %]</a>
[% END %]
[% map_html = BLOCK %]
diff --git a/web/js/map-google-ol.js b/web/js/map-google-ol.js
index a0e58cdc2..5a1aa3c57 100644
--- a/web/js/map-google-ol.js
+++ b/web/js/map-google-ol.js
@@ -1,11 +1,18 @@
$(function(){
- $('#map_layer_toggle').toggle(function(){
- $(this).text(translation_strings.map_satellite);
- fixmystreet.map.setBaseLayer(fixmystreet.map.layers[1]);
- }, function(){
- $(this).text(translation_strings.map_map);
- fixmystreet.map.setBaseLayer(fixmystreet.map.layers[0]);
+ $('#map_layer_toggle').on('click', function(e){
+ e.preventDefault();
+ var $t = $(this), text = $t.text();
+ if (text == translation_strings.map_map) {
+ $t.text(translation_strings.map_satellite);
+ fixmystreet.map.setBaseLayer(fixmystreet.map.layers[0]);
+ } else {
+ $t.text(translation_strings.map_map);
+ fixmystreet.map.setBaseLayer(fixmystreet.map.layers[1]);
+ }
});
+ if (typeof fixmystreet_google_default !== 'undefined' && fixmystreet_google_default == 'satellite') {
+ $('#map_layer_toggle').click();
+ }
});
function set_map_config(perm) {
@@ -25,9 +32,10 @@ function set_map_config(perm) {
fixmystreet.map_options = {
zoomDuration: 10
};
+
fixmystreet.layer_options = [
- { type: google.maps.MapTypeId.HYBRID },
- {}
+ {},
+ { type: google.maps.MapTypeId.HYBRID }
];
}