From 0e96f3f02e25f2555f122e043cba36ccf3758a7e Mon Sep 17 00:00:00 2001 From: Tom Russell Date: Thu, 2 Aug 2018 16:55:49 +0100 Subject: [PATCH] Only add highlight layer when ready --- frontend/main.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/main.js b/frontend/main.js index 9094f7af..3743e539 100755 --- a/frontend/main.js +++ b/frontend/main.js @@ -50,7 +50,7 @@ function map(){ maxZoom: 20, minZoom: 14 }) - highlight_layer.addTo(map); + var highlight_layer_added = false; // Query for building on click map.on('click', function(e){ @@ -64,6 +64,9 @@ function map(){ if (data.geometry_id){ highlight_layer.setUrl('/tiles/highlight/{z}/{x}/{y}.png?highlight='+data.geometry_id) } + if (!highlight_layer_added && data.geometry_id){ + highlight_layer.addTo(map); + } }) })