From d57f9f7a604636a48fbcf578d2dd772dbf9f4477 Mon Sep 17 00:00:00 2001 From: Petr Sloup Date: Wed, 29 Jun 2016 20:23:37 +0200 Subject: [PATCH] Fix and improve xray viewer --- public/templates/data.tmpl | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/public/templates/data.tmpl b/public/templates/data.tmpl index 084606a..abb2662 100644 --- a/public/templates/data.tmpl +++ b/public/templates/data.tmpl @@ -103,12 +103,18 @@ var propertyList = document.getElementById('propertyList'); map.on('mousemove', function(e) { propertyList.innerHTML = ''; - map.featuresAt(e.point, {radius: 3}, function(err, features) { - if (err) throw err; - if (features[0]) { - propertyList.innerHTML = JSON.stringify(features[0].properties, null, 2); - } - }); + var width = 3, height = 3; + var features = map.queryRenderedFeatures([ + [e.point.x - width / 2, e.point.y - height / 2], + [e.point.x + width / 2, e.point.y + height / 2] + ]); + if (features) { + var html = ''; + features.forEach(function(feature) { + html += JSON.stringify(feature.properties, null, 2) + '\n'; + }); + propertyList.innerHTML = html; + } }); {{/is_vector}}