Only add highlight layer when ready

This commit is contained in:
Tom Russell 2018-08-02 16:55:49 +01:00
parent 3ab86180e7
commit 0e96f3f02e

View File

@ -50,7 +50,7 @@ function map(){
maxZoom: 20, maxZoom: 20,
minZoom: 14 minZoom: 14
}) })
highlight_layer.addTo(map); var highlight_layer_added = false;
// Query for building on click // Query for building on click
map.on('click', function(e){ map.on('click', function(e){
@ -64,6 +64,9 @@ function map(){
if (data.geometry_id){ if (data.geometry_id){
highlight_layer.setUrl('/tiles/highlight/{z}/{x}/{y}.png?highlight='+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);
}
}) })
}) })