From 810ec21eb79c822f7aa3b4cf600a28f0072c6708 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Fri, 14 May 2021 17:25:42 +0200 Subject: [PATCH] Switch to a table for showing possible OSM matches --- static/js/map.js | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/static/js/map.js b/static/js/map.js index 1bfd83e..0a8cf34 100644 --- a/static/js/map.js +++ b/static/js/map.js @@ -438,33 +438,36 @@ function mouse_events(marker, qid) { var nearby = response.data.nearby; if (!nearby.length) return; var osm_html = "Possible OSM matches
"; + osm_html += '' + osm_html += '' for (const osm of nearby) { - var span_id = osm.identifier.replace("/", "_"); - nearby_lookup[span_id] = osm; - osm_html += ` ${osm.distance.toFixed(0)}m ` + var candidate_id = osm.identifier.replace("/", "_"); + osm_html += `"; } + osm_html += "
${osm.distance.toFixed(0)}m `; + osm_html += ``; + osm_html += ''; + osm_html += ""; + nearby_lookup[candidate_id] = osm; + // osm_html += ` ${osm.distance.toFixed(0)}m ` + if (osm.name) { + osm_html += osm.name + " "; + } + if (!osm.presets.length && !osm.name) { + osm_html += "no name "; + } osm_html += osm.presets.map(function(p) { var wiki_url = `http://wiki.openstreetmap.org/wiki/${p.tag_or_key}`; return `${p.name} `; }).join(", "); - if (osm.presets.length && osm.name) { - osm_html += ": "; - } - if (osm.name) { - osm_html += osm.name; - } - if (!osm.presets.length && !osm.name) { - osm_html += " no name"; - } if (osm.address_list && osm.address_list.length) { if (osm.address_list.length == 1) { - osm_html += " address node: " + osm.address_list[0]; + osm_html += "
address node: " + osm.address_list[0]; } else { - osm_html += " address nodes: " + osm.address_list.join("; ") + osm_html += "
address nodes: " + osm.address_list.join("; ") } } - osm_html += ` ` - osm_html += '

'; + osm_html += "
" candidates.innerHTML = osm_html; var span_list = document.getElementsByClassName("osm-candidate");