From c30ae857af7f2e2bccf974da34cf2f3868e7b7f2 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Thu, 4 Jul 2019 21:12:12 +0100 Subject: 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. --- web/js/map-OpenLayers.js | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'web/js/map-OpenLayers.js') 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(); -- cgit v1.2.3