diff --git a/static/js/map.js b/static/js/map.js index 2ade739..59928fd 100644 --- a/static/js/map.js +++ b/static/js/map.js @@ -271,8 +271,9 @@ function set_isa_list(isa_count_list) { function build_item_detail(item, tag_or_key_list) { var wd_url = "https://www.wikidata.org/wiki/" + item.qid; + var popup = '
' - var popup = "

Wikidata item
"; + popup += "Wikidata item
"; popup += `${item.label} (${item.qid})`; if (item.description) { popup += `
description
${item.description}`; @@ -285,6 +286,7 @@ function build_item_detail(item, tag_or_key_list) { popup += `
${isa_label} (${isa_qid})`; } } + popup += '

' if (tag_or_key_list && tag_or_key_list.length) { popup += "
OSM tags/keys to search for"; @@ -298,7 +300,7 @@ function build_item_detail(item, tag_or_key_list) { popup += `
${item.street_address[0]["text"]}`; } - popup += "

"; + popup += "
"; return popup; } @@ -356,6 +358,19 @@ function close_item_details() { } } +function show_outline(osm) { + if (candidate_outline !== undefined) { + candidate_outline.removeFrom(map); + } + + var mapStyle = { fillOpacity: 0, color: "red" }; + var geojson = L.geoJSON(null, { style: mapStyle }); + geojson.addData(osm.geojson); + geojson.addTo(map); + + candidate_outline = geojson; +} + function mouse_events(marker, qid) { items[qid] ||= {}; var item = items[qid]; @@ -422,8 +437,11 @@ function mouse_events(marker, qid) { for (const osm of nearby) { var span_id = osm.identifier.replace("/", "_"); nearby_lookup[span_id] = osm; - osm_html += ` ${osm.distance.toFixed(1)}m ` - osm_html += osm.presets.join(", "); + osm_html += ` ${osm.distance.toFixed(0)}m ` + 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 += ": "; } @@ -433,24 +451,15 @@ function mouse_events(marker, qid) { if (!osm.presets.length && !osm.name) { osm_html += "no name"; } - osm_html += "
"; + osm_html += ` ` + osm_html += '

'; } candidates.innerHTML = osm_html; var span_list = document.getElementsByClassName("osm-candidate"); + for (const osm_span of span_list) { - osm_span.onmouseover = function (e) { - osm = nearby_lookup[e.target.id]; - - if (candidate_outline !== undefined) { - candidate_outline.removeFrom(map); - } - - var mapStyle = { fillOpacity: 0, color: "red" }; - var geojson = L.geoJSON(null, { style: mapStyle }); - geojson.addData(osm.geojson); - geojson.addTo(map); - - candidate_outline = geojson; + osm_span.onmouseenter = function (e) { + show_outline(nearby_lookup[e.target.id]); }; } }); diff --git a/web_view.py b/web_view.py index ca866aa..fadf218 100755 --- a/web_view.py +++ b/web_view.py @@ -785,14 +785,27 @@ def get_presets_from_tags(tags): preset_dir = app.config["ID_PRESET_DIR"] found = [] for k, v in tags.items(): + if k == 'amenity' and v == 'clock' and tags.get('display') == 'sundial': + tag_or_key = f"Tag:{k}={v}" + found.append({"tag_or_key": tag_or_key, "name": "Sundial"}) + continue + filename = os.path.join(preset_dir, k, v + ".json") - if not os.path.exists(filename): - filename = os.path.join(preset_dir, k + ".json") - if not os.path.exists(filename): - continue + if os.path.exists(filename): + tag_or_key = f"Tag:{k}={v}" + else: + filename = os.path.join(preset_dir, k, "_" + v + ".json") + if os.path.exists(filename): + tag_or_key = f"Tag:{k}={v}" + else: + filename = os.path.join(preset_dir, k + ".json") + if os.path.exists(filename): + tag_or_key = f"Key:{k}" + else: + continue data = json.load(open(filename)) name = data["name"] - found.append(name) + found.append({"tag_or_key": tag_or_key, "name": name}) return found