diff options
author | Matthew Somerville <matthew@mysociety.org> | 2019-07-04 21:12:12 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2019-07-10 15:53:27 +0100 |
commit | c30ae857af7f2e2bccf974da34cf2f3868e7b7f2 (patch) | |
tree | d5237c547791a17786ac6e40735bea7a7ea75a2e /web/js/map-OpenLayers.js | |
parent | 12d234639171b0965c2ce5cf0fea5a6af180cc9b (diff) |
Improve map JavaScript defensiveness.
Add more checking for map things so e.g. on a skipped map page
we stop getting JavaScript errors given there is no map present.
Diffstat (limited to 'web/js/map-OpenLayers.js')
-rw-r--r-- | web/js/map-OpenLayers.js | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index ae86269c9..cd2283491 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -304,6 +304,9 @@ $.extend(fixmystreet.utils, { // fixmystreet.select_feature). markers_highlight: function(problem_id) { + if (!fixmystreet.markers) { + return; + } for (var i = 0; i < fixmystreet.markers.features.length; i++) { if (typeof problem_id == 'undefined') { // There is no highlighted marker, so unfade this marker @@ -791,6 +794,10 @@ $.extend(fixmystreet.utils, { $(function(){ + if (!document.getElementById('map')) { + return; + } + // Set specific map config - some other JS included in the // template should define this fixmystreet.maps.config(); |