diff --git a/static/js/map.js b/static/js/map.js index 4628bc3..d4e89d8 100644 --- a/static/js/map.js +++ b/static/js/map.js @@ -13,6 +13,7 @@ if (start_lat || start_lng) { var map = L.map("map", options); var group = L.featureGroup(); +var items = {}; var wikidata_items = {}; var osm_objects = {}; var wikidata_loaded = false; @@ -210,16 +211,23 @@ function checkbox_change() { if(osm_objects[qid]) { osm_objects[qid].forEach(osm => { - if (intersection.length) { - osm.marker.addTo(group); - } else { - osm.marker.removeFrom(group); - } + if (intersection.length) { + osm.marker.addTo(group); + } else { + osm.marker.removeFrom(group); + } }); } - - + if(items[qid]) { + items[qid].geojson.forEach(geojson => { + if (intersection.length) { + geojson.addTo(map); + } else { + geojson.removeFrom(map); + } + }); + } } } @@ -262,6 +270,34 @@ function set_isa_list(isa_count) { }); } +function add_wikidata_marker(item, marker_data) { + var icon = blueMarker; + var label = `${item.label} (${item.qid})` + var marker = L.marker(marker_data, {icon: icon}); + // var tooltip = marker.bindTooltip(item.qid, {permanent: true, direction: 'bottom', opacity: 0.5}); + var wd_url = 'https://www.wikidata.org/wiki/' + item.qid; + var popup = '
Wikidata item
'
+ popup += `${item.label} (${item.qid})`
+ if (item.description) {
+ popup += `
description: ${item.description}`
+ }
+ if (item.isa_list && item.isa_list.length) {
+ popup += '
item type'
+ for (const [index, isa_qid] of item.isa_list.entries()) {
+ var isa_url = 'https://www.wikidata.org/wiki/' + isa_qid;
+ var isa_label = isa_labels[isa_qid];
+ popup += `
${isa_label} (${isa_qid})`;
+ }
+ }
+ if (item.image_list && item.image_list.length) {
+ popup += `
`;
+ }
+ popup += '
Wikidata item
'
- popup += `${item.label} (${item.qid})`
- if (item.description) {
- popup += `
description: ${item.description}`
- }
- if (item.isa_list && item.isa_list.length) {
- popup += '
item type'
- for (const [index, isa_qid] of item.isa_list.entries()) {
- var isa_url = 'https://www.wikidata.org/wiki/' + isa_qid;
- var isa_label = isa_labels[isa_qid];
- popup += `
${isa_label} (${isa_qid})`;
- }
- }
- if (item.image_list && item.image_list.length) {
- popup += `
`;
- }
- popup += '